{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":32108,"path":"it-service-management/devops-change-velocity/dev-ops-github-apps-oauth-auth.md","title":"OAuth 2.0 credentials for GitHub Apps - Authorization Code","bundle":null,"doc_type":null,"release":"australia","body":"\n# OAuth 2.0 credentials for GitHub Apps - Authorization Code\n\nPerform the following steps to integrate your GitHub Apps using Authorization code.\n\n**Before you begin**\n\nRole required:\n\n-   oauth\\_admin in DevOps Change Velocity.\n-   Admin account in GitHub.\n\n**Note:** Only user-level repositories are supported. You must have access to all the GitHub repositories that you want to configure in DevOps Change Velocity using Authorization code.\n\nThe OAuth Authorization Code grant type is supported for GitHub &amp; GitHub Enterprise with MID server.\n\n## Configure the GitHub App in your GitHub account \\(Authorization Code\\)\n\nCreate a custom GitHub App from your GitHub account to enable OAuth 2.0 authentication with your ServiceNow instance.\n\n### Before you begin\n\nGitHub requirement: GitHub App configured to integrate with ServiceNow\n\nRole required: No instance role required\n\n### About this task\n\nComplete these steps from your GitHub account. See [Building GitHub Apps](https://developer.github.com/apps/building-github-apps/) on the GitHub Developer site for instructions on creating and configuring custom applications.\n\n### Procedure\n\n1.  From your GitHub account, create your GitHub App by navigating to **Developer Settings** &gt; **GitHub Apps**.\n\n2.  In the **Homepage URL** field, enter `https://<instance-name>.service-now.com`.\n\n3.  In the **User authorization callback URL** field, enter `https://<instance-name>.service-now.com/oauth_redirect.do`.\n\n4.  In the **Identifying and authorizing users** section, deselect the **Expire user authorization tokens** field.\n\n5.  In the **Webhook** section, deselect the **Active** field.\n\n6.  Leave the remaining fields empty \\(default\\).\n\n7.  In the **Repository permissions** section, configure these settings.\n\n<table id=\"table_j5m_wcs_4mb\"><tbody><tr><td>\n\nAction\n\n</td><td>\n\nRead-only\n\n</td></tr><tr><td>\n\nChecks\n\n</td><td>\n\nRead-only\n\n</td></tr><tr><td>\n\nContents\n\n</td><td>\n\nRead-only\n\n</td></tr><tr><td>\n\nDeployments\n\n</td><td>\n\nRead and write\n\n</td></tr><tr><td>\n\nEnvironments\n\n</td><td>\n\nRead-only\n\n</td></tr><tr><td>\n\nMetadata\n\n</td><td>\n\nRead-only\n\n</td></tr><tr><td>\n\nPull requests\n\n</td><td>\n\nRead-only\n\n</td></tr><tr><td>\n\nSecrets\n\n</td><td>\n\nRead-only\n\n</td></tr><tr><td>\n\nWebhooks\n\n</td><td>\n\nRead and write**Note:** Read and write permissions are required to configure webhooks from ServiceNow.\n\n</td></tr></tbody>\n</table>8.  Leave the remaining permissions as `No access` \\(default\\).\n\n9.  Install the newly created GitHub App on the accounts of your choice.\n\n\n## Register GitHub as an OAuth Provider \\(Authorization Code\\)\n\nUse the information generated during GitHub App account configuration to register GitHub as an OAuth provider and allow the instance to request OAuth 2.0 tokens.\n\n### Before you begin\n\nRole required: admin, sn\\_devops.admin\n\n### Procedure\n\n1.  Navigate to **All** &gt; **System OAuth** &gt; **Application Registry**.\n\n2.  Click **New**.\n\n    The system displays the message **What kind of OAuth application?**\n\n3.  Select **Connect to a third party OAuth Provider**.\n\n    The system displays an empty Application Registries form.\n\n4.  Complete the form.\n\n<table id=\"table_fd2_2xr_4mb\"><thead><tr><th>\n\nField\n\n</th><th>\n\nValue required\n\n</th></tr></thead><tbody><tr><td>\n\nName\n\n</td><td>\n\nEnter any name to uniquely identify the record. For example, enter `My GitHub App Provider`.\n\n</td></tr><tr><td>\n\nClient ID\n\n</td><td>\n\nEnter the client ID of your GitHub App \\(hint: available in the **About** section of your GitHub App configuration in GitHub \\).\n\n</td></tr><tr><td>\n\nClient Secret\n\n</td><td>\n\nEnter the client secret of your GitHub App \\(hint: available in the **About** section of your GitHub App configuration in GitHub \\).\n\n</td></tr><tr><td>\n\nOAuth API script\n\n</td><td>\n\nSelect **OAuthDevOpsGitHubHandler**.\n\n</td></tr><tr><td>\n\nDefault Grant type\n\n</td><td>\n\nSelect **Authorization Code**.\n\n</td></tr><tr><td>\n\nAuthorization URL\n\n</td><td>\n\nEnter `https://github.com/login/oauth/authorize`.\n\n For an on-premises deployment, use the proper GitHub host URL.\n\n</td></tr><tr><td>\n\nToken URL\n\n</td><td>\n\nEnter `https://github.com/login/oauth/access_token`.\n\n For an on-premises deployment, use the proper GitHub host URL.\n\n</td></tr></tbody>\n</table>5.  Leave the rest of the form fields as default.\n\n    \\[Omitted image \"github-oauth-auth-app-registries.png\"\\] Alt text: Application Registry form\n\n6.  Right-click the form header, and click **Save**.\n\n    -   The system validates the OAuth credentials and populates the **Redirect URL** \\(Hint: It should match the **User authorization callback URL** previously provided in your GitHub App configuration\\).\n    -   The system populates **OAuth Entity Profile** with **Grant Type** as **Authorization Code**. For example, **OAuth Entity Profile** is created with default **Name**, **My GitHub App Provider default\\_profile**\n\n## Create a credential record for GitHub App provider \\(Authorization Code\\)\n\nCreate a credential record to the GitHub App provider previously created to authorize actions.\n\n### Before you begin\n\nRole required: admin, credential\\_admin\n\n### Procedure\n\n1.  Navigate to **All** &gt; **Connections &amp; Credentials** &gt; **Credentials**.\n\n2.  Click **New**.\n\n    The system displays the message **What type of Credentials would you like to create?**.\n\n3.  Select **OAuth 2.0 Credentials**.\n\n    The pop-up window displays an empty OAuth 2.0 Credentials form.\n\n4.  Fill in these values.\n\n<table id=\"table_sxv_zgp_gfb\"><thead><tr><th>\n\nField\n\n</th><th>\n\nValue required\n\n</th></tr></thead><tbody><tr><td>\n\nName\n\n</td><td>\n\nEnter any name to uniquely identify the record. For example, enter `My GitHub App Credential`.\n\n</td></tr><tr><td>\n\nActive\n\n</td><td>\n\nEnable\n\n</td></tr><tr><td>\n\nOAuth Entity Profile\n\n</td><td>\n\nSelect the default OAuth Entity profile you created previously.\n\n</td></tr><tr><td>\n\nApplies to\n\n</td><td>\n\nSelect the MID Servers that can use this credential. For example, select **All MID Servers**.**Note:** You must connect to your GitHub tool instance using MID Server to use this credential.\n\n</td></tr><tr><td>\n\nOrder\n\n</td><td>\n\nSelect the order to apply this credential. For example, enter `100`.\n\n</td></tr></tbody>\n</table>5.  Save the record.\n\n6.  Click the **Get OAuth Token** related link to generate the OAuth token.\n\n\n**Related topics**  \n\n\n[GitHub Actions configurations]()\n\n[ServiceNow DevOps custom actions from GitHub marketplace]()\n\n"}}