POST
/api/oauth2/token
Request a new token.
To get a token with administrator credentials you provide the "client_id" and "client_secret".
To get a token with user or thing credentials you must provide the "username" and "password".
To get a token with a refresh token you must provide the "refresh_token" and the "grant_type".
As user and things are entities that can be authenticated by Kii Cloud they are considered also as principals when referring authentication contexts, the principalID would be in those cases the userID or thingID.
Content-Type application/vnd.kii.OauthTokenRequest+json
All the required information to request a token. We advise to use prefixed addresses. application/json can be used as content-type for the compatibility.
- The login name of the user
- The email address of the user
- The email address of the user with prefix: EMAIL:{emailAddress}
- The phone number of the user in international format: +XXX...
- The phone number of the user in local format: PHONE:{countryCode}-{localPhone}
The country code is in ISO-3166 format. The phone number and email address must be verified.
For getting a thing token, the vendorThingID with the prefix: VENDOR_THING_ID:{vendorThingID} must be providedThe client_id for the OAuth2 authorization flow
- The Kii application's clientID for getting an app admin token
- The Kii application's appID for getting an anonymous token
The client_secret for the OAuth2 authorization flow
- The Kii application's clientSecret for getting an app admin token
- The Kii application's appKey for getting an anonymous token
{
"username": "[string]",
"password": "[string]",
"expiresAt": "[long]",
"client_id": "[string]",
"client_secret": "[string]",
"refresh_token": "[string]",
"grant_type": "[string]"
}
Content-Type application/json
Name | Type | Description |
---|---|---|
id | string | The ID of the principal (user or thing). |
access_token | string | The access token issued by the authorization server. |
expires_in | long | The lifetime of the access token (in seconds). |
token_type | string | The token type. Only "Bearer" is supported. |
refresh_token | string | The new refresh token. |
Content-Type application/json
Name | Type | Description |
---|---|---|
errorCode | string | Oauth2 error code: "invalid_grant" or "unsupported_grant_type". |
error_description | string | The error description. |
error | string | Oauth2 error code |