User Oauth Tokens Actions
https://api.losant.com/me/oauth-tokens
Below are the various requests that can be performed against the User Oauth Tokens resource, as well as the expected parameters and the potential responses.
Get
Returns the OAuth tokens for a user
Method And Url
GET https://api.losant.com/me/oauth-tokens
Authentication
A valid API access token is required to access this endpoint. The token must
include at least one of the following scopes:
all.User, all.User.bounded, all.User.read, only.User, only.User.bounded, only.User.read, userOauthTokens.*, or userOauthTokens.get.
Request Query Parameters
| Name | Required | Description | Default | Example |
|---|---|---|---|---|
| sortField | N | Field to sort the results by. Accepted values are: name, status, id, creationDate, lastUpdated | name | sortField=name |
| sortDirection | N | Direction to sort the results by. Accepted values are: asc, desc | asc | sortDirection=asc |
| page | N | Which page of results to return | 0 | page=0 |
| perPage | N | How many items to return per page | 100 | perPage=10 |
| filterField | N | Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name | filterField=name | |
| filter | N | Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. | filter=my*app |
Request Headers
| Name | Required | Description | Default |
|---|---|---|---|
| Authorization | Y | The token for authenticating the request, prepended with Bearer |
Curl Example
curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X GET \
https://api.losant.com/me/oauth-tokens
Successful Responses
| Code | Type | Description |
|---|---|---|
| 200 | User OAuth Tokens | Collection of OAuth tokens |
Error Responses
| Code | Type | Description |
|---|---|---|
| 400 | Error | Error if malformed request |
Post
Create a new OAuth token for a user
Method And Url
POST https://api.losant.com/me/oauth-tokens
Authentication
A valid API access token is required to access this endpoint. The token must
include at least one of the following scopes:
all.User, only.User, userOauthTokens.*, or userOauthTokens.post.
Request Headers
| Name | Required | Description | Default |
|---|---|---|---|
| Authorization | Y | The token for authenticating the request, prepended with Bearer |
Request Body
The body of the request should be serialized JSON that validates against the User OAuth Token Post schema. For example, the following would be a valid body for this request:
{
"name": "My OAuth App",
"description": "OAuth application for automation",
"scope": [
"only.User.read",
"all.Application.read"
],
"defaultRole": "view",
"oauth": {
"client_id": "575ec8687ae143cd83dc4a97",
"redirect_uri": "https://example.com/callback",
"code_challenge": "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM",
"code_challenge_method": "S256"
}
}
Curl Example
curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X POST \
-d '{"name":"My OAuth App","description":"OAuth application for automation","scope":["only.User.read","all.Application.read"],"defaultRole":"view","oauth":{"client_id":"575ec8687ae143cd83dc4a97","redirect_uri":"https://example.com/callback","code_challenge":"E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM","code_challenge_method":"S256"}}' \
https://api.losant.com/me/oauth-tokens
Successful Responses
| Code | Type | Description |
|---|---|---|
| 201 | User OAuth Token | The successfully created OAuth token |
Error Responses
| Code | Type | Description |
|---|---|---|
| 400 | Error | Error if malformed request |
Schemas
Error
Schema for errors returned by the API
Error Schema
- ▶{} 3 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 2 keys
- ▶{} 1 key
- ▶{} 1 key
Error Example
- ▶{} 2 keys
- "NotFound"
- "Application was not found"
User OAuth Token
Schema for a single OAuth Token
User OAuth Token Schema
- ▶{} 3 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 12 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 3 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 3 keys
- ▶{} 4 keys
- ▶{} 2 keys
- ▶{} 2 keys
User OAuth Token Example
- ▶{} 11 keys
- "575ec7417ae143cd83dc4a95"
- "575ec7417ae143cd83dc4a95"
- "My OAuth App"
- "OAuth application for automation"
- "2016-06-13T04:00:00.000Z"
- "2016-06-13T04:00:00.000Z"
- ▶[] 2 items
- "view"
- [] 0 items
- "active"
- ▶{} 6 keys
User OAuth Token Post
Schema for the body of an OAuth Token creation request
User OAuth Token Post Schema
- ▶{} 5 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 7 keys
- ▶{} 3 keys
- ▶{} 2 keys
- ▶{} 2 keys
- ▶{} 4 keys
- ▶{} 2 keys
- ▶{} 3 keys
- ▶{} 4 keys
- false
- ▶[] 2 items
User OAuth Token Post Example
- ▶{} 5 keys
- "My OAuth App"
- "OAuth application for automation"
- ▶[] 2 items
- "view"
- ▶{} 4 keys
User OAuth Tokens
Schema for a collection of OAuth Tokens
User OAuth Tokens Schema
- ▶{} 3 keys
- "http://json-schema.org/draft-07/schema#"
- "object"
- ▶{} 9 keys
- ▶{} 2 keys
- ▶{} 1 key
- ▶{} 1 key
- ▶{} 1 key
- ▶{} 1 key
- ▶{} 1 key
- ▶{} 1 key
- ▶{} 1 key
- ▶{} 2 keys
User OAuth Tokens Example
- ▶{} 7 keys
- ▶[] 1 item
- 1
- 1
- 1000
- 0
- "name"
- "asc"
Was this page helpful?
Still looking for help? You can also search the Losant Forums or submit your question there.