Next: Non-Web Application Flow, Previous: Web Application Flow, Up: Authorize an OAuth App [Index]
The device flow allows you to authorize users for a headless app, such as a CLI tool or Git credential manager.
Overview of the device flow:
https://github.com/login/device.
POST https://github.com/login/device/code
Your app must request a user verification code and verification URL that the app will use to prompt the user to authenticate in the next step. This request also returns a device verification code that the app must use to receive an access token and check the status of user authentication.
(string) Requirerd The client ID you received from GitHub for your app.
(string) The scope that your app is requesting access to.
{ "device_code": "3584d83530557fdd1f46af8289938c8ef79f9dc5", "user_code": "WDJB-MJHT", "verification_uri": "https://github.com/login/device", "expires_in": 900, "interval": 5 }
(string) The device verification code is 40 characters and used to verify the device.
(string) The user verification code is displayed on the device so the user can enter the code in a browser. This code is 8 characters with a hyphen in the middle.
The verification URL where users need to enter the user_code:
https://github.com/login/device
(integer) The number of seconds before the device_code and user_code expire. The default is 900 seconds or 15 minutes.
(integer) The minimum number of seconds that must pass before you can make a new access token request (POST https://github.com/login/oauth/access_token) to complete the device authorization.
Your device will show the user verification code and prompt the user to enter the code at
https://github.com/login/device.
Your app will make device authorization requests that poll
POST https://github.com/login/oauth/access_token
until the device and user codes expire or the user has successfully authorized the app with a valid user code. The app must use the minimum polling interval retrieved in step 1 to avoid rate limit errors.
The user must enter a valid code within 15 minutes (or 900 seconds). After 15 minutes, you will need to request a new device authorization code with
POST https://github.com/login/device/code
Once the user has authorized, the app will receive an access token that can be used to make requests to the API on behalf of a user.
(string) Required The client ID you received from GitHub for your OAuth App.
(string) Required The device verification code you received from the request to:
POST https://github.com/login/device/code
(string) Required The grant type must be:
urn:ietf:params:oauth:grant-type:device_code
{ "access_token": "e72e16c7e42f292c6912e7710c838347ae178b4a", "token_type": "bearer", "scope": "user" }
Next: Non-Web Application Flow, Previous: Web Application Flow, Up: Authorize an OAuth App [Index]