Perform an authentication call
You must implement the RESTful service interface on the client side. This is necessary in order to send a request for the authorization code prior to sending a data request. By default, the posted authorization code must be used within 20 minutes for data request calls to the Alfabet RESTful API. You can create the client interface to either request a new authorization key before each data request call or in regular time intervals. The authorization period can be changed on request.
The authorization call must be sent to the following URL:
- URLOfTheAlfabetAPIServer/api/token
The specification of the URL for all calls to the Alfabet RESTful services is case-sensitive.
The method for the call is POST.
The Content-Type field of the HTTP header must be defined as Content-Type: application/x-www-form-urlencoded.
The body of the request must be defined as grant_type=password&username=youralfabetRESTusername&password=youralfabetRESTuserAPIpassword
The answer is a JSON response with the following structure:
- {
- "token_type": "bearer"
- access_token":"token"
- "expires_in": 1200
- }
The expires_in field returns the time that the token is valid in seconds.
The calls to the Alfabet RESTful API must be sent to the following URL, whereby URLOfTheAlfabetAPIServer must be amended with the endpoint specification as described in the following chapters:
- URLOfTheAlfabetAPIServer/api/v2/EndpointName
The data in the response of the authorization call must be added as the authorization key to the header of all requests sent to the Alfabet RESTful API. The following format is required:
- Authorization:TypeValue
Type is the value in the token_type field and Value is the value in the access_token field.
Authorization call:
Service call: https://AlfabetCloud/AlfabetAPIServer/api/token
HTTP method: POST
Header (Key:Value): Content-Type: application/x-www-form-urlencoded
Body: grant_type=password&username=RESTAdmin&password=2GKT6DZFNMJUENFOKPNSPHTO3ZHEBEB5
Response of the authorization call:
- {
- "token_type": "bearer"
- access_token":"eyJ0eXAiOiJKVxMiJ9.eyJpc3MiOiJhbGZhYmV0IiwiaWF0IjoiMTU3MzAzMjA0NiIsImV4cCI6IjE1NzMwMzMyNDYiLCJxc2giOm51bGwsInN1YiI6IkFwaSBBdXRoZW50aWNhdGlvbiIsImNvbnRleHQiOnsidXNlciI6eyJVc2VyS2V5IjoiQUxGQUJFRDRUNGNc1R5cGUiOjB9fX0.PJC0EWtlUETbraV7NckVkRTFVm356y6K9JyhFR245hXp-2ApttryATZ_dAL0bi_GZpeJx7iqr_lRIA"
- "expires_in": 1200
- }
Authorization header of service calls following the authorization call:
- Authorization: bearer eyJ0eXAiOiJKVxMiJ9.eyJpc3MiOiJhbGZhYmV0IiwiaWF0IjoiMTU3MzAzMjA0NiIsImV4cCI6IjE1NzMwMzMyNDYiLCJxc2giOm51bGwsInN1YiI6IkFwaSBBdXRoZW50aWNhdGlvbiIsImNvbnRleHQiOnsidXNlciI6eyJVc2VyS2V5IjoiQUxGQUJFRDRUNGNc1R5cGUiOjB9fX0.PJC0EWtlUETbraV7NckVkRTFVm356y6K9JyhFR245hXp-2ApttryATZ_dAL0bi_GZpeJx7iqr_lRIA