How to Use an ID Token

OpenID Connect (OIDC) is an extended authentication protocol based on OAuth 2.0, which allows you to securely acquire an authenticated user's information.

After going through the authorization process, you can get both an access token that is used to make an API call and an ID token to authenticate a user. An ID token can be used for SSO integration (IdP).

ID token use flow

1. Get an ID token {#id-token-issue}

Getting an ID token requires authentication with a user account.

Caution

  • Getting an ID token requires authentication with a user account. You cannot get an ID token by authentication with a service account.

2. Verify an ID token {#id-token-validation}

To verify an ID token, you need to check all of the following:

  1. payload > iss claim: It must exactly match the issuer specified in openid-configuration.
  2. payload > aud claim: It must match the client ID of the app.
  3. payload > nonce: It must be the same as the nonce requested in the authorization request.
  4. payload > iat, exp: The current time must be between iat and exp.
  5. header > kid, alg: Create a public key with certs using the kid header and verify the signature of id_token with the algorithm in the alg header.

3. Verify an access token {#access-token-validation}

Follow the instructions below.

  1. Get the hash value of access_token with the hash algorithm specified in the alg header of the ID token.
  2. Divide the hash value in half, Base64 URL-encode the first part, and then check if it is the same as the payload > at_hash of the ID token.

4. Use an ID token {#id-token-use}

Verify an ID token before using it. An ID token contains the information of the authenticated user.


ID token specification {#id-token}

As a JSON Web Token (JWT) signed with JSON Web Signature (JWS), an ID token consists of a header, payload, and signature.

Header {#id-token-header}

PropertyRequiredDescription
typRequiredJWT
algRequiredRS256
kidRequiredKey ID for the signature

Payload {#id-token-payload}

claimRequiredDescription
issRequiredIssuer
It must match the issuer of openid-configuration.
subRequiredMember ID
audRequiredThe app's client ID issued by the Developer Console
nonceOptionalThe nonce value passed by the authorization request.
It is required if a nonce is specified in the authorization request.
emailOptionalLINE WORKS account. It is usually in the form of an email, but it may not be if a group name is used as the domain.
・ Available if the email scope is selected.
nameOptionalRepresentative name
・ Available if the profile scope is selected.
localeOptionalLanguage codes (ko_KR, ja_JP, en_US, zh_CN, zh_TW)
・ Available if the profile scope is selected.
expRequiredJWT expiration time.
It is in Unix time format (in sec).
It expires after 1 hour.
iatRequiredJWT creation time.
It is in Unix time format (in sec).
at_hashOptionalThe hash value of the access token.
It is used to verify the access token.
It is required in the implicit flow.
email_verifiedOptionalAccount validity.
It is always true because email is a LINE WORKS account.
・ Available if the email scope is selected.
family_nameOptionalLast name
・ Available if the profile scope is selected.
given_nameOptionalFirst name
・ Available if the profile scope is selected.

openid-configuration {#openid-configuration}

It specifies the OIDC specifications of LINE WORKS.
Comply with OpenID Connect Discovery 1.0.

Request URL {#openid-configuration-request-url}

https://auth.worksmobile.com/{tenantId}/.well-known/openid-configuration

HTTP request {#openid-configuration-request-method}

GET

Path parameters {#openid-configuration-request-parameter}

PropertyTypeDescription
tenantIdStringTenant ID

Request example {#openid-configuration-request-example}

curl -location -request GET 'https://auth.worksmobile.com/1111/.well-known/openid-configuration'

Response {#openid-configuration-response}

HTTP 200 OK

PropertyTypeDescription
issuerStringIssuer
authorization_endpointStringOAuth 2.0 Authorization Endpoint URL
token_endpointStringOAuth2.0 Token Endpoint URL
revocation_endpointStringOAuth2.0 Revocation Endpoint URL
jwks_uriStringJWK document URL
scopes_supportedArray (string)Scopes supported by OIDC
grant_types_supportedArray (string)grant_types supported by OIDC
subject_types_supportedArray (string)Subject identifier types supported
id_token_signing_alg_values_supportedArray (string)id_token signature algorithm
token_endpoint_auth_methods_supportedArray (string)Authentication method supported by the token endpoint
claims_supportedArray (string)Items supported by id_token claim

Response example {#openid-configuration-response-example}

{  "issuer": "https://auth.worksmobile.com",  "authorization_endpoint": "https://auth.worksmobile.com/oauth2/v2.0/authorize",  "token_endpoint": "https://auth.worksmobile.com/oauth2/v2.0/token",  "revocation_endpoint": "https://auth.worksmobile.com/oauth2/v2.0/revoke",  "end_session_endpoint": "https://auth.worksmobile.com/oauth2/v2.0/logout",  "jwks_uri": "https://auth.worksmobile.com/oauth2/v2.0/certs/1111",  "scopes_supported": [    "openid",    "email",    "profile"  ],  "response_types_supported": [    "code",    "id_token",    "token id_token"  ],  "grant_types_supported": [    "authorization_code",    "implicit",    "refresh_token"  ],  "subject_types_supported": [    "public"  ],  "id_token_signing_alg_values_supported": [    "RS256"  ],  "token_endpoint_auth_methods_supported": [    "client_secret_post"  ],  "claims_supported": [    "iss",    "aud",    "sub",    "iat",    "exp",    "email",    "email_verified",    "family_name",    "given_name",    "name",    "locale",    "app_ver"  ]}

certs {#oidc-certs}

It returns the public key information to be used to verify the signature of the ID token. The rotation cycle is 30 days.

Request URL {#oidc-certs-request-url}

https://auth.worksmobile.com/oauth2/v2.0/certs/{tenantId}

HTTP method {#oidc-certs-request-method}

GET

Response {#oidc-certs-response}

HTTP 200

OK

PropertyTypeDescription
ktyStringKey Type
Set this to "RSA".
useStringPublic Key User
Set this to "sig" (signature).
algStringAlgorithm
Set this to "RS256".
kidStringKey ID
ID of non-duplicate key
eStringExponent
RSA public key exponent
※ Signs are not included.
nStringModulus
RSA public key modulus
※ Signs are not included.

Response example {#oidc-certs-response-example}

{  "keys": [    {      "kty": "RSA",      "use": "sig",      "alg": "RS256",      "kid": "gnwk3n8rna",      "e": "AQAB",      "n": "ge42jbjjksdgajh23bjtaeg"    },    {      "kty": "RSA",      "use": "sig",      "alg": "RS256",      "kid": "wlgoai49eg",      "e": "AQAB",      "n": "kfiwuheg8skhvbgi23ligoh"    }  ]}