Requesting Bearer Tokens
It is possible to call the API with credentials and request the corresponding bearer token using the getuser endpoint. This allows developers to prompt for credentials, obtain the corresponding bearer token, and then use the token for the duration of the session without storing any authentication information in source code or databases.
The getuser endpoint supports getting information about a user's token or profile using either a GET or POST method. The following example shows requesting the token, and presumes that the user's credentials are passed in the basic header.
POST /api/v1/getuser HTTP/1.1 Host: api.statebook.com Content-Type: application/json Authorization: Bearer demo { "data": { "token" ] } var response = { "data": { "token": "...", } }, "status": { "id": "b5f658b1-6829-4fc5-97c7-30ee099d9beb", "timestamp": "2020-01-15T19:17:27.228509Z", "version": "1.0.0", "license": "The data returned from this StateBook Data API call is restricted and may only be used in accordance with the terms of a current and valid StateBook Data API license. Any other use is strictly prohibited." } }
Requesting User Profiles
It is also possible to call the API with credentials or a token and request the corresponding profile using the GET or POST methods of the getuser endpoint. The credentials are passed in the Basic header, and a token is passed in the Bearer header. For POST requests, the token can also be passed as a parameter.
The following example shows requesting the profile and presumes that the user's token is passed in the Bearer header.
POST /api/v1/getuser HTTP/1.1 Host: api.statebook.com Content-Type: application/json Authorization: Bearer demo { "data": { "profile" ] } var response = { { "data": { "profile": { "username": "demo", "firstName": "Demo", "lastName": "User" } }, "status": { "id": "b5f658b1-6829-4fc5-97c7-30ee099d9beb", "timestamp": "2020-01-15T19:17:27.228509Z", "version": "1.0.0", "license": "The data returned from this StateBook Data API call is restricted and may only be used in accordance with the terms of a current and valid StateBook Data API license. Any other use is strictly prohibited." } }
Comments
0 comments
Article is closed for comments.