Two-Factor Authentication
Perform two-factor authentication in Autoshares Trader
Last updated
Perform two-factor authentication in Autoshares Trader
Last updated
All API requests in Autoshares WebTrader requires a unique authentication token that must be provided in the request header. Without this token, it's impossible to place orders, retrieve charts, create users, etc. To get the token, use the following API endpoint:
If the user's account has two-factor authentication enabled, the authentication process involves two separate requests:
First request: retrieval of the interim token;
Second request: retrieval of the authentication token.
The header of the first request must contain the following three parameters:
Et-App-Key. This is the unique key of your app that identifies your app when communicating with our service. Contact your administrator to get this key.
Username. This is the username of the user on whose behalf all future requests will be made.
Password. This is the password of the user on whose behalf all future requests will be made.
The header of the second request must contain the following three parameters:
Et-App-Key. This is the unique key of your app that identifies your app when communicating with our service. Contact your administrator to get this key.
Username. This is the username of the user on whose behalf all future requests will be made.
Password. This is the password of the user on whose behalf all future requests will be made.
VerificationCode (header). This is the verification code that's sent by email or as an SMS message (depending on the the user's settings).
Authorization (header). This is the authorization token that will be returned in response to the initial request.
The following are sample CURLs for performing two-factor authentication:
In response to the first API request, you'll receive a JSON file that contains the interim token. Here's an example of such response:
Also notice that the response contains the Token parameter that must be used in the subsequent request as a header parameter in the following format:
"Authorization" : "Bearer + tokenFromTheFirstRequest"
In total, the header of the second request must contain five parameters:
Username (identical to the first request);
Password (identical to the first request);
Et-App-Key (identical to the first request);
Authorization (Bearer + token);
VerificationCode (the code received by email or SMS).
In response to the second request, you'll receive the following JSON dictionary:
The token parameter from the second request must be provided as the Authorization
parameter in all future requests like placing orders, retrieving user's positions, etc.
Here are some of the common mistakes that developers make when requesting an authorization token:
If you specify the wrong Et-App-Key parameter or fail to include it in the header altogether, you'll get the following error:
If you specify the wrong user credentials or fail to include them in the request header, you'll get the following error:
In the following article we outline in detail all of the required and optional header parameters, the range of response status codes, as well as a comprehensive list of all possible responses.
Another common mistake that developers make during authentication is failure to provide the authorization token that is retrieved during the first request of a two-factor authentication. If the token is not provided in the request header, the entire authentication process will be rendered corrupt:
In the following article we provide in-depth coverage of the syntax for this API request.
To see how two-factor authentication can be performed in code, feel free to examine our in a dedicated article.