Device authorization
The OAuth device authorization grant type allows a user to grant authorization to the device client using a browser on a second device, typically a smartphone or computer.
This grant type is typically used to access a protected resource through a device that lacks a browser or has limited user input capabilities, such as a smart TV or appliance.
The device authorization grant process takes place between the user, device, PingOne authorization server, and the Resource Server (RS). For more information about the grant type, see the OAuth 2.0 Device Authorization Grant specification.
-
The device sends a device authorization request to PingOne, the authorization server at its device authorization endpoint.
-
PingOne returns a device authorization response. Among other parameters, the response contains a device code, a user code, and a verification URI.
-
The device provides the verification URI in a query parameter and instructions to the user, as in the following example:
Using a browser on another device, visit: https://www.example.com Enter the code: HVF7-B4KW
-
The device starts sending token requests to PingOne to poll whether the user has completed the authorization process.
The token request must include the device authorization grant type,
urn:ietf:params:oauth:grant-type:device_code
, the device code, and the user code.For each token request it receives, PingOne returns a response. The payload varies depending on the authorization status.
-
The user completes the authorization process by:
-
Going to the verification URI on a second device that has a browser, such as a smartphone or a computer.
-
Fulfilling the authentication requirements.
-
Entering the user code or confirming a prepopulated user code.
-
Approving or denying the scope of permissions requested by the device.
-
-
The device continues polling PingOne for an authorization status.
-
PingOne validates the user code and provides the device with an access token (and an ID token if applicable) in the token response.
If the user denies the scope of permissions, PingOne provides the device with a relevant error message in the token response.
-
The device provides the access token to the resource server to access protected resources.
-
The resource server validates the access token.
-
The resource server provides the requested data to the device.
Related links
Sample browser redirect flow
The user turns on their smart TV and starts a streaming app called ShowMe for the first time.
-
The ShowMe app sends a device authorization request to PingOne.
-
PingOne returns a device authorization response to the ShowMe app.
The device authorization response includes the verification URI, the user code (activation code), and the device code, among other response parameters.
The ShowMe app then:
-
Presents the user code and verification URI through a QR code, a short URL, or both.
-
Prompts the user to scan the QR code to open the verification URI or enter the short URL on a smartphone, tablet, or computer.
-
Starts polling PingOne at the token endpoint with the device code it received from PingOne. PingOne returns an authorization pending message to the ShowMe app in the token responses until the user completes the next step.
The user:
-
Opens the verification URI on their smartphone, tablet, or computer.
-
Completes the authentication process.
-
Confirms the activation code that’s shown on the smart TV.
-
Authorizes the request.
When the user authorizes the request, PingOne returns security tokens to the ShowMe app the next time it sends a token request.
Sample user interactions
When the user opens the verification URI on the smartphone, tablet, or computer, the short URL redirects the browser to PingOne. PingOne prompts the user to complete the authentication process.
If the user completes the authentication process successfully, PingOne prompts the user to enter the activation code.
If the user enters the correct code shown by the streaming app on the smart TV, PingOne then prompts the user to authorize the request. The Application Consent page shows the name of the application and the authenticated user.
If the user approves the request, PingOne shows a message stating that the request is authorized. The user can then close the browser.
The next time the ShowMe app polls PingOne at the token endpoint, PingOne returns an access token and ID token if it’s requested.