Authenticate and authorize requests to the API using tokens

Brief

The article teaches how to authenticate and authorize requests to the API using tokens.

Details

The FCLite API requires a JWT to be passed in order to authenticate. The third-party OAuth authentication model allows a third-party application to direct the end user to an authentication page. After successful authentication, the user is redirected back to the third-party application, which then provides the token.

The authorization_code grant type allows token exchange in the back channel and is completely hidden to the end user.

3rd Party application must launch the login page

https://{fxcm_domain}/oauth/authorize?client_id={client_id}&response_type=code&redirect_uri={redirect_uri}&scope=openid%20trading

Required parameters:

Production Real: https://oauth.fxcorporate.com

Production Demo: https://oauth-demo.fxcorporate.com

UAT: https://oauthu.fxcorporate.com

QA: https://oauthq.fxcorporate.com

Optional parameters:

The user enter their FXCM login credentials. The user will be prompted to and must subsequently approve the request. Server will redirect back to {redirect_uri} with the query parameter: code. Third party application will receive response with header.location: {redirect_uri}?code={code} It submit a POST. POST BODY must contain:

Client receives JSON response: {access_token: access_token, refresh_token: refresh_token, token_type: ‘Bearer’}

Third party application may submit post to get new access token through the refresh mechanism: https://{fxcm_domain}/oauth2/token

Or it may submit post to logout and clear cookies: https://{fxcm_domain}/oauth2/logout

You can authenticate and authorize requests to the FCLite API using the method IFXConnectLiteSession.attach.

Class IFXConnectLiteSession is the interface that provides access to the trading system.

The method attach logs the user in to the trading system. The function's parameters include the JSON web token, the URL of the server and the name of the connection.

Logout Hide

typescriptjavascript
function attach(jwt: string, tradingSystemUrl: string, connection: string);

Questions and answers

1. What is the purpose of authentication and authorization to APIs using tokens?

The main advantage is security. Since login password can be intercepted or picked up by an attacker, while a token has a short life span and is issued by a specific service that is trusted by the client.

2. In what cases will the information from the article be useful?

The information from the article will be useful in cases where you integrate into the NewCo EcoSystem and when the token is sufficient to access one system from another.

3. Where can I obtain the JSON web token for the attach method?

The JSON web token required for the attach method is provided by a service within the NewCo EcoSystem. It is not accessible to ordinary users and is specifically designed for integration with NewCo.

back