Basic Authentication
Last updated
Last updated
In this example, there's a class called AutosharesAPIRequest
that has five properties:
baseURL
— this is the URL that hosts your API. Each solution has its own base URL for both the Trader and the Developer API.
EtAppKey
— this is the unique key of your solution that can be retrieved from the BO companies widget in Autoshares Trader.
Token
— this is the authentication token that must be provided in all API requests except for the first one (authentication).
Username
and password
— these are the credentials of a user on whose behalf all API requests will be made.
The first method — initialAuth
— creates a POST request to the base URL appended by token
(each endpoint has its own unique address). As for headers, the authentication endpoint requires you to provide the following parameters:
"Accept" : "application/json"
— use this parameter to accept the authorization token that will be returned in response to this request.
EtAppKey
— use this parameter to identify your app in all requests.
Username
and password
— these are the credentials of the user on whose behalf all subsequent requests will be made.
In response to this request, you'll receive a JSON file that contains the token (provided that all the parameters were correctly specified):
You can then extract the returned token and assign it to the token
property.
The following is a sample CURL for performing single-factor authentication: