Get API Keys
In order to use Totogi API Platform APIs, you should use your credentials to get an access token which is required for every API call. Totogi API Platform uses Oauth2 for authorization. Following steps describe how you can retrieve access tokens using your credentials and the client ID.
Getting an Access Token from the Command Line
- Create a file called
auth.json
that contains your username, password & client id. Example:
{
"AuthParameters": {
"USERNAME": "mbreslow@verizon.com",
"PASSWORD": "Snack@tack83271"
},
"AuthFlow": "USER_PASSWORD_AUTH",
"ClientId": "s9gwjl9mbz4gsqqczdbagnvzjk"
}
- Obtain tokens from AWS Cognito
curl -X POST --data @auth.json -H "X-Amz-Target: AWSCognitoIdentityProviderService.InitiateAuth" -H "Content-Type: application/x-amz-json-1.1" https://cognito-idp.us-east-1.amazonaws.com/
The output is a JSON document like this one:
{
"AuthenticationResult": {
"AccessToken": "eyJraWQiOiJ2XC84Vn...",
"ExpiresIn": 86400,
"IdToken": "eyJraWQiOiJYNTBtQ001...",
"RefreshToken": "eyJjdHkiOiJKV1Q...",
"TokenType": "Bearer"
},
"ChallengeParameters": {}
}
- Extract the AccessToken from the AuthenticationResult. You can use the jq command
curl -X POST --data @auth.json -H "X-Amz-Target: AWSCognitoIdentityProviderService.InitiateAuth" -H "Content-Type: application/x-amz-json-1.1" https://cognito-idp.us-east-1.amazonaws.com/ | jq -r ".AuthenticationResult.AccessToken"