All Products
Search
Document Center

Identity as a Service:Authorization information

Last Updated:Mar 31, 2026

CIAM uses OAuth 2.0 and OpenID Connect (OIDC) for authentication and authorization. This page covers how to authenticate API requests and acquire tokens using each supported grant type.

Authentication methods

CIAM supports two API authentication methods depending on where your code runs.

Server-side authentication

Use server-side authentication for API calls between servers. Acquire an access token with grant_type=client_credentials, then pass it on each request using one of the following formats:

Query parameter:

https://xxx/h5/login/pwd?access_token=eyJhbGciOiJIUzI1NiIs****......fiMzvKNaWAxKfHI-3NG

Request header (bearer token):

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5......fiMzvKNaWAxKfHI-3NGndKzo_VOZjLoI

For details on the bearer token format, see RFC 6750.

Client-side authentication

Use client-side authentication only for authentication APIs running in browsers, apps, or miniapps. Add the following custom request headers to each call:

idaasSign: hex(sha1.encode(idaasAppId+idaasTimeStamp))
idaasAppId: <your Application ID from the IDaaS console>
idaasTimeStamp: new Date().getTime()

Where idaasSign is a hex-encoded SHA-1 signature of your Application ID concatenated with the current timestamp.

Token acquisition

CIAM supports the following grant types. Choose based on your application type:

Grant typeUse when
Client Credentials GrantYour code runs server-side with no user context (machine-to-machine)
Authorization Code GrantUsers log in via a browser and your app has a server-side component
Implicit GrantYour app is a Single-Page Application (SPA) with no server-side component
Resource Owner Password Credentials GrantYour app collects user credentials directly and exchanges them for a token
Refresh TokenYou have an existing refresh token and need to get a new access token
Implicit Grant does not return a refresh_token. Client Credentials Grant also does not return a refresh_token.

Scopes

The scope parameter controls what the token can access. Include one or more values, separated by spaces.

ScopeUse for
APPLICATION_APIRegular application APIs
MANAGEMENT_APPLICATION_APIManagement application APIs
USER_APIUser-context APIs — required for Authorization Code Grant, Implicit Grant, and Refresh Token flows
openidInclude when you need an ID token returned
profileUser profile claims
emailUser email claims
phoneUser phone number claims
readRead-only access

Client Credentials Grant

Gets a bearer token for server-to-server API authorization. No user context is involved and no refresh_token is returned.

Endpoint: POST /api/bff/v1.2/developer/ciam/oauth/token

Content-Type: application/json

Request parameters

ParameterTypeRequiredDescription
client_idstringYesYour appKey from IDaaS
client_secretstringYesYour appSecret from IDaaS
grant_typestringYesFixed value: client_credentials
scopestringNoUse APPLICATION_API for regular application APIs, or MANAGEMENT_APPLICATION_API for management APIs

Example request

curl --request POST \
  --url 'https://<your-domain>/api/bff/v1.2/developer/ciam/oauth/token' \
  --header 'Content-Type: application/json' \
  --data '{
    "client_id": "<your-appKey>",
    "client_secret": "<your-appSecret>",
    "grant_type": "client_credentials",
    "scope": "APPLICATION_API"
  }'

Replace the following placeholders:

PlaceholderDescription
<your-domain>Your CIAM domain, for example xxxx.login.aliyunidaas.com
<your-appKey>The appKey from the IDaaS console application list
<your-appSecret>The appSecret from the IDaaS console application list

Response parameters

ParameterTypeExampleDescription
access_tokenstringeyJhbG1N**********ttXBrTNQgThe access token
token_typestringbearerThe token type
expires_inlong3600Token lifetime in seconds
scopestringcreateThe authorization scope granted

Authorization Code Grant

Exchanges an authorization code for a user token. Use this when your app redirects users to CIAM for login and receives a code at the callback URL.

Endpoint: POST /api/bff/v1.2/developer/ciam/oauth/token

Content-Type: application/json

Request parameters

ParameterTypeRequiredDescription
client_idstringYesYour appKey from IDaaS
client_secretstringYesYour appSecret from IDaaS
grant_typestringYesFixed value: authorization_code
scopestringYesMust include USER_API. Include openid to receive an ID token. Separate multiple values with a space.
codestringYesAuthorization code received at the callback URL
redirect_uristringYesCallback URL registered in the IDaaS application settings

Example request

curl --request POST \
  --url 'https://<your-domain>/api/bff/v1.2/developer/ciam/oauth/token' \
  --header 'Content-Type: application/json' \
  --data '{
    "client_id": "<your-appKey>",
    "client_secret": "<your-appSecret>",
    "grant_type": "authorization_code",
    "scope": "USER_API openid",
    "code": "<authorization-code>",
    "redirect_uri": "<your-callback-url>"
  }'

Replace the following placeholders:

PlaceholderDescription
<your-domain>Your CIAM domain
<your-appKey>The appKey from the IDaaS console
<your-appSecret>The appSecret from the IDaaS console
<authorization-code>The code received in the callback
<your-callback-url>The callback URL registered in IDaaS, for example https://yourapp.example.com/callback

Response parameters

ParameterTypeExampleDescription
access_tokenstringeyJhbG1N**********ttXBrTNQgThe access token
refresh_tokenstringeyJhbG1N**********ttXBrTNQgUsed to refresh the access token
token_typestringbearerThe token type
id_tokenstringeyJhbG1NiIsI******ttXBrTNQgID token — returned only when scope includes openid
expires_inlong3600Token lifetime in seconds
scopestringUSER_APIThe authorization scope granted

Implicit Grant

Gets a user token directly from the authorization endpoint. Use this for SPAs and other client-side apps with no server-side component.

Implicit Grant does not return a refresh_token.

Endpoint: GET /api/bff/v1.2/developer/ciam/oauth/authorize

Request parameters

ParameterTypeRequiredDescription
client_idstringYesYour appKey from IDaaS
response_typestringYesFixed value: token
scopestringYesMust include USER_API. Include openid to receive an ID token. Separate multiple values with a space.
redirect_uristringYesCallback URL registered in the IDaaS application settings. URL-encode this value.
statestringNoA random value used to prevent cross-site request forgery (CSRF). The authorization server returns this value unchanged in the callback.

Example request

GET {ciam.example.com}/api/bff/v1.2/developer/ciam/oauth/authorize?response_type=token&client_id=KnUPlQlqm
    &scope=USER_API%20APPLICATION_API%20read%20openid%20profile%20email&state=123
    &redirect_uri=https://xxxxx

Response parameters

ParameterTypeExampleDescription
access_tokenstringeyJhbG1NiIsI******ttXBrTNQgThe access token
token_typestringbearerThe token type
id_tokenstringeyJhbG1NiIsI******ttXBrTNQgID token — returned only when scope includes openid
expires_inlong3600Token lifetime in seconds
scopestringUSER_APIThe authorization scope granted
statestringxxxxThe state value passed in the request

Refresh token

Exchanges a refresh token for a new access token. Use this to maintain user sessions without requiring re-authentication.

Endpoint: POST /api/bff/v1.2/developer/ciam/oauth/token

Content-Type: application/json

Request parameters

ParameterTypeRequiredDescription
client_idstringYesYour appKey from IDaaS
client_secretstringYesYour appSecret from IDaaS
grant_typestringYesFixed value: refresh_token
scopestringYesMust include USER_API. Include openid to receive an ID token. Separate multiple values with a space.
refresh_tokenstringYesThe user's refresh token

Example request

curl --request POST \
  --url 'https://<your-domain>/api/bff/v1.2/developer/ciam/oauth/token' \
  --header 'Content-Type: application/json' \
  --data '{
    "client_id": "<your-appKey>",
    "client_secret": "<your-appSecret>",
    "grant_type": "refresh_token",
    "scope": "USER_API openid",
    "refresh_token": "<your-refresh-token>"
  }'

Response parameters

ParameterTypeExampleDescription
access_tokenstringeyJhbG1NiIsI******ttXBrTNQgThe access token
refresh_tokenstringeyJhbG1NiIsI******ttXBrTNQgThe refresh token
token_typestringbearerThe token type
id_tokenstringeyJhbG1NiIsI******ttXBrTNQgID token — returned only when scope includes openid
expires_inlong3600Token lifetime in seconds
scopestringUSER_APIThe authorization scope granted

OIDC service discovery

Returns OpenID Connect metadata for the CIAM authorization server. Use this endpoint to programmatically configure your OIDC client library.

If you are integrating CIAM with a framework that requires an issuer address (for example, Spring Security), use:

https://<baseUrl>/api/bff/v1.2/developer/ciam/oidc/<idaasAppId>

Endpoint: GET /api/bff/v1.2/developer/ciam/oidc/<idaasAppId>/.well-known/openid-configuration

Request parameters

ParameterTypeRequiredDescription
idaasAppIdstringYesApplication ID from the IDaaS console Application Management list

Example response

{
    "issuer": "https://xxxx.login.aliyunidaas.com/api/bff/v1.2/developer/ciam/oidc/idaas_ciam_public_cn_-xxxx",
    "authorization_endpoint": "https://xxxx.login.aliyunidaas.com/api/bff/v1.2/developer/ciam/oauth/authorize",
    "userinfo_endpoint": "https://xxxx.login.aliyunidaas.com/api/bff/v1.2/developer/ciam/user/profile",
    "token_endpoint": "https://xxxx.login.aliyunidaas.com/api/bff/v1.2/developer/ciam/oidc/token",
    "jwks_uri": "https://xxxx.login.aliyunidaas.com/api/bff/v1.2/developer/ciam/oidc/idaas_ciam_public_cn_-xxxx/.well-known/jwks.json",
    "end_session_endpoint": "https://xxxx.login.aliyunidaas.com/api/bff/v1.2/developer/ciam/user/logout",
    "introspection_endpoint": "https://xxxx.login.aliyunidaas.com/api/bff/v1.2/developer/ciam/user/token/check",
    "reject_endpoint": "https://xxxx.login.aliyunidaas.com/api/bff/v1.2/developer/ciam/user/oauth/device/reject",
    "response_types_supported": ["code", "token", "id_token", "id_token token"],
    "request_parameter_supported": true,
    "request_uri_parameter_supported": true,
    "claims_parameter_supported": true,
    "require_request_uri_registration": false,
    "grant_types_supported": [
        "authorization_code",
        "client_credentials",
        "refresh_token",
        "implicit",
        "password",
        "urn:ietf:params:oauth:grant-type:device_code"
    ],
    "scopes_supported": [
        "APPLICATION_API", "USER_API", "read", "openid", "profile", "email", "phone"
    ],
    "claims_supported": [
        "sub", "iss", "aud", "nbf", "nickname", "exp", "iat", "jti",
        "nonce", "username", "email", "email_verified",
        "phone_number", "phone_number_verified", "externalId", "preferred_username"
    ],
    "subject_types_supported": ["public"],
    "id_token_signing_alg_values_supported": ["RS256"],
    "token_endpoint_auth_methods_supported": ["client_secret_post"],
    "response_modes_supported": ["fragment", "query"]
}

Error response

If idaasAppId is invalid or the application has been disabled:

{
    "error_description": "[xxx]The application does not exist or has been disabled",
    "requestId": "1663756588639$d7da5416-ad73-7230-3f7d-f0bd618804e5",
    "error": "invalid_client",
    "error_uri": "xxxx/api/bff/v1.2/developer/ciam/oidc/xxx/.well-known/openid-configuration"
}