server/api/oauth.js
function proxyOAuth( request, response ) {
	// We are making a password request, and want all the 2fa checks enabled
	const data = Object.assign(
		{},
		{
			username: request.body.username,
			password: request.body.password,
		},
		oauth()
	);

	if ( request.body.auth_code ) {
		// Pass along the one-time password
		data.wpcom_otp = request.body.auth_code;
	}

	req
		.post( config( 'desktop_oauth_token_endpoint' ) )
		.type( 'form' )
		.send( data )
		.end(
			validateOauthResponse( response, function( error, res ) {
				// Return the token as a response
				response.json( res.body );
			} )
		);
}
function proxyOAuth( request, response ) {
	// We are making a password request, and want all the 2fa checks enabled
	const data = Object.assign(
		{},
		{
			username: request.body.username,
			password: request.body.password,
		},
		oauth()
	);

	if ( request.body.auth_code ) {
		// Pass along the one-time password
		data.wpcom_otp = request.body.auth_code;
	}

	req
		.post( config( 'desktop_oauth_token_endpoint' ) )
		.type( 'form' )
		.send( data )
		.end(
			validateOauthResponse( response, function( error, res ) {
				// Return the token as a response
				response.json( res.body );
			} )
		);
}
/*
Proxies an oauth login request to the WP API
We need to do this to get around CORS issues with making the request directly from the Electron browser