Skip to content

Commit 8db5a66

Browse files
indigokskedwards88
andauthored
Add more error types to OAuth token request troubleshooting (github#36869)
Co-authored-by: skedwards88 <[email protected]>
1 parent 0ad1448 commit 8db5a66

File tree

2 files changed

+53
-9
lines changed

2 files changed

+53
-9
lines changed

content/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-user-access-token-for-a-github-app.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,42 @@ You can generate a user access token with this method regardless of whether the
136136
By default, user access tokens expires after 8 hours. If you receive a user access token with an expiration, you will also receive a refresh token. The refresh token expire after 6 months. You can use this refresh token to regenerate a user access token. For more information, see "[AUTOTITLE](/apps/creating-github-apps/authenticating-with-a-github-app/refreshing-user-access-tokens)."
137137

138138
{% data variables.product.company_short %} strongly encourages you to use user access tokens that expire. If you previously opted out of using user access tokens that expire but want to re-enable this feature, see "[AUTOTITLE](/apps/maintaining-github-apps/activating-optional-features-for-github-apps)".
139+
140+
## Troubleshooting
141+
142+
The following sections outline some errors you may receive when generating a user access token.
143+
144+
### Incorrect client credentials
145+
146+
If the `client_id` or `client_secret` that you specify are incorrect, you will receive an `incorrect_client_credentials` error.
147+
148+
To resolve this error, make sure to use the correct credentials for your {% data variables.product.prodname_github_app %}. You can find the client ID and client secret on the settings page for your {% data variables.product.prodname_github_app %}. For more information about navigating to your {% data variables.product.prodname_github_app %} settings page, see "[AUTOTITLE](/apps/maintaining-github-apps/modifying-a-github-app-registration#navigating-to-your-github-app-settings)."
149+
150+
### Redirect URI mismatch
151+
152+
If you specify a `redirect_uri` that doesn't match one of the callback URLs in your {% data variables.product.prodname_github_app %} registration, you will receive a `redirect_uri_mismatch` error.
153+
154+
To resolve this error, either provide a `redirect_uri` that matches one of the callback URLs for your {% data variables.product.prodname_github_app %} registration, or omit this parameter to default to the first callback URL that is listed on your {% data variables.product.prodname_github_app %} registration. For more information, see "[AUTOTITLE](/apps/creating-github-apps/registering-a-github-app/about-the-user-authorization-callback-url)."
155+
156+
### Bad verification code
157+
158+
If you are using device flow and the verification code (`device_code`) that you specified is incorrect, expired, or doesn't
159+
match the value that you received from the initial request to `{% data variables.product.oauth_host_code %}/login/device/code`, you will receive a `bad_verification_code` error.
160+
161+
To resolve this error, you should start the device flow again to get a new code. For more information, see "[Using the device flow to generate a user access token](#using-the-device-flow-to-generate-a-user-access-token)."
162+
163+
### Bad refresh token
164+
165+
If the refresh token that you specified is invalid or expired, you will receive a `bad_refresh_token` error.
166+
167+
To resolve this error, you must restart the web application flow or device flow to get a new user access token and refresh token. You will only receive a refresh token if your {% data variables.product.prodname_github_app %} has opted in to expiring user access tokens. For more information, see "[AUTOTITLE](/apps/creating-github-apps/authenticating-with-a-github-app/refreshing-user-access-tokens)."
168+
169+
### Unsupported grant type
170+
171+
When you request a user access token via the device flow, the `grant_type` parameter must be `urn:ietf:params:oauth:grant-type:device_code`. When you refresh a user access token by using a refresh token, the `grant_type` parameter must be `refresh_token`. If you don't use the correct grant type, you will receive an `unsupported_grant_type` error.
172+
173+
### Unverified user email
174+
175+
If the user for whom you are trying to generate a user access token has not verified their primary email address with {% data variables.product.company_short %}, you will receive an `unverified_user_email` error.
176+
177+
To resolve this error, prompt the user to verify the primary email address on their {% data variables.product.company_short %} account. For more information, see {% ifversion fpt or ghec %}"[AUTOTITLE](/get-started/signing-up-for-github/verifying-your-email-address)."{% else %}"[AUTOTITLE](/free-pro-team@latest/get-started/signing-up-for-github/verifying-your-email-address)" in the {% data variables.product.prodname_free_user %} documentation.{% endif %}

content/apps/oauth-apps/maintaining-oauth-apps/troubleshooting-oauth-app-access-token-request-errors.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,6 @@ registered with your application.
5555

5656
## Bad verification code
5757

58-
```json
59-
{
60-
"add_scopes": [
61-
"repo"
62-
],
63-
"note": "admin script"
64-
}
65-
```
66-
6758
If the verification code you pass is incorrect, expired, or doesn't
6859
match what you received in the first request for authorization you will
6960
receive this error.
@@ -78,3 +69,17 @@ receive this error.
7869

7970
To solve this error, start the [OAuth authorization process again](/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps)
8071
and get a new code.
72+
73+
## Unverified user email
74+
75+
If the user for whom you are trying to generate a user access token has not verified their primary email address with {% data variables.product.company_short %}, you will receive this error.
76+
77+
```json
78+
{
79+
"error": "unverified_user_email",
80+
"error_description": "The user must have a verified primary email.",
81+
"error_uri": "/apps/managing-oauth-apps/troubleshooting-oauth-app-access-token-request-errors/#unverified_user_email"
82+
}
83+
```
84+
85+
To resolve this error, prompt the user to verify the primary email address on their {% data variables.product.company_short %} account. For more information, see {% ifversion fpt or ghec %}"[AUTOTITLE](/get-started/signing-up-for-github/verifying-your-email-address)."{% else %}"[AUTOTITLE](/free-pro-team@latest/get-started/signing-up-for-github/verifying-your-email-address)" in the {% data variables.product.prodname_free_user %} documentation.{% endif %}

0 commit comments

Comments
 (0)