Table of Contents
This article describes some Authlete APIs for retrieving, changing and revoking authorization granted for a client by a user. They would be useful in some use cases, for example:
/client/authorization/get/list API provides a list of clients which have been authorized a certain user (i.e. which have had tokens granted by the user).
A request will be made using either GET or POST.
GET /api/client/authorization/get/list/<subject>
GET /api/client/authorization/get/list?subject=<subject>
POST /api/client/authorization/get/list
application/x-www-form-urlencoded
POST /api/client/authorization/get/list
application/json
Request parameters are as follows.
Item | Description |
---|---|
subject | Unique user ID \*REQUIRED |
start | Start index of search results, inclusive (The default value is 0) |
end | End index of search results, exclusive (The default value is 5) |
developer | Unique Developer ID (The default value is null) |
JSON including the following parameters is provided with status code 200.
Item | Description |
---|---|
start | Start index of search results (inclusive) |
end | End index of search results (exclusive) |
developer | Unique developer ID |
totalCount | The total number of clients that meet the conditions |
clients | An array of clients. Format of the client information is the same as ones in other responses of some APIs e.g. /client/get |
subject | Unique user ID |
The following JSON object is provided with status code 400, 403, 500 etc.
application/json
{
"resultCode": ...,
"resultMessage": ...
}
The following example is a request to retrieve a list of clients granted authorization by user "testuser01" .
curl -s -X POST $AL_API/client/authorization/get/list \
-u ...:... \
-H 'Content-type: application/json' \
-d '{"subject":"testuser01"}'
Authlete sends back a response including a list of clients in "clients" .
{
"type": "authorizedClientListResponse",
"clients": [
{
"clientId": 17566160603766,
"clientIdAliasEnabled": false,
"clientName": "FAPI Client",
"developer": "authlete_14500880170338"
}
],
"end": 5,
"start": 0,
"totalCount": 1,
"subject": "testuser01"
}
/client/authorization/update API allows an authorization server to update scopes of tokens for a single client, which have been granted by a certain user.
A request will be made using POST. Its URL includes clientId.
POST /api/client/authorization/update/<clientId>
application/x-www-form-urlencoded
POST /api/client/authorization/update/<clientId>
application/json
Request parameters are as follows.
Item | Description |
---|---|
subject | Unique user ID \*REQUIRED |
scopes | An array of new scopes |
JSON including the following parameters is provided with status code 200, 400, 403, 500 etc.
application/json
{
"resultCode": ...,
"resultMessage": ...
}
The following example is a request to update tokens issued to a client "17566160603766" as per granted by a user "testuser01" . A new value of “scopes” for the tokens will be "payment" .
curl -s -X POST $AL_API/client/authorization/update/17566160603766
\
-u ...:... \
-H 'Content-type: application/json' \
-d '{
"subject":"testuser01", "scopes":"payment"
}'
Authlete send back a response stating that the access tokens have been updated.
{
"resultCode": "A138001",
"resultMessage": "[A138001] Updated 4 access token(s)
issued to the client (ID = 17566160603766) of the service (API Key = ...)."
}
/client/authorization/delete API allows authorization server to revoke tokens by specifying both a client and a user.
A request will be made using either DELETE or POST. Its URL includes clientId.
DELETE /api/client/authorization/delete/<clientId>/<subject>
DELETE /api/client/authorization/delete/<clientId>?subject=<subject>
POST /api/client/authorization/delete/<clientId>
application/x-www-form-urlencoded
POST /api/client/authorization/delete/<clientId>
application/json
Request parameters are as follows.
Item | Description |
---|---|
subject | Unique user ID \*REQUIRED |
JSON including the following parameters is provided with status code 200, 400, 403, 500 etc.
application/json
{
"resultCode": ...,
"resultMessage": ...
}
The following example is a request to delete tokens issued to a client "17566160603766" as per granted by a user "testuser01" .
curl -s -X POST $AL_API/client/authorization/delete/17566160603766
\
-u ...:... \
-H 'Content-type: application/json' \
-d '{
"subject":"testuser01"
}'
Authlete send back a response stating that the access tokens have been deleted.
{
"resultCode": "A137001",
"resultMessage": "[A137001] Deleted 4 access token(s)
issued to the client (ID = 17566160603766) of the service (API Key = ...)."
}