|
| 1 | +--- |
| 2 | +title: Configure GitHub authentication |
| 3 | +description: Learn how to configure GitHub authentication as an identity provider for your App Service or Azure Functions app. |
| 4 | +ms.topic: article |
| 5 | +ms.date: 03/01/2022 |
| 6 | +--- |
| 7 | + |
| 8 | +# Configure your App Service or Azure Functions app to use GitHub login |
| 9 | + |
| 10 | +[!INCLUDE [app-service-mobile-selector-authentication](../../includes/app-service-mobile-selector-authentication.md)] |
| 11 | + |
| 12 | +This article shows how to configure Azure App Service or Azure Functions to use GitHub as an authentication provider. |
| 13 | + |
| 14 | +To complete the procedure in this article, you need a GitHub account. To create a new GitHub account, go to [GitHub]. |
| 15 | + |
| 16 | +## <a name="register"> </a>Register your application with GitHub |
| 17 | + |
| 18 | +1. Sign in to the [Azure portal] and go to your application. Copy your **URL**. You'll use it to configure your GitHub app. |
| 19 | +1. Follow the instructions for [creating an OAuth app on GitHub](https://docs.github.com/developers/apps/building-oauth-apps/creating-an-oauth-app). In the **Authorization callback URL** section, enter the HTTPS URL of your app and append the path `/.auth/login/github/callback`. For example, `https://contoso.azurewebsites.net/.auth/login/github/callback`. |
| 20 | +1. On the application page, make note of the **Client ID**, which you will need later. |
| 21 | +1. Under **Client Secrets**, select **Generate a new client secret**. |
| 22 | +1. Make note of the client secret value, which you will need later. |
| 23 | + |
| 24 | + > [!IMPORTANT] |
| 25 | + > The client secret is an important security credential. Do not share this secret with anyone or distribute it with your app. |
| 26 | +
|
| 27 | +## <a name="secrets"> </a>Add GitHub information to your application |
| 28 | + |
| 29 | +1. Sign in to the [Azure portal] and navigate to your app. |
| 30 | +1. Select **Authentication** in the menu on the left. Click **Add identity provider**. |
| 31 | +1. Select **GitHub** in the identity provider dropdown. Paste in the `Client ID` and `Client secret` values that you obtained previously. |
| 32 | + |
| 33 | + The secret will be stored as a slot-sticky [application setting](./configure-common.md#configure-app-settings) named `GITHUB_PROVIDER_AUTHENTICATION_SECRET`. You can update that setting later to use [Key Vault references](./app-service-key-vault-references.md) if you wish to manage the secret in Azure Key Vault. |
| 34 | + |
| 35 | +1. If this is the first identity provider configured for the application, you will also be prompted with an **App Service authentication settings** section. Otherwise, you may move on to the next step. |
| 36 | + |
| 37 | + These options determine how your application responds to unauthenticated requests, and the default selections will redirect all requests to log in with this new provider. You can change customize this behavior now or adjust these settings later from the main **Authentication** screen by choosing **Edit** next to **Authentication settings**. To learn more about these options, see [Authentication flow](overview-authentication-authorization.md#authentication-flow). |
| 38 | + |
| 39 | +1. Click **Add**. |
| 40 | + |
| 41 | +You're now ready to use GitHub for authentication in your app. The provider will be listed on the **Authentication** screen. From there, you can edit or delete this provider configuration. |
| 42 | + |
| 43 | +<!-- URLs. --> |
| 44 | + |
| 45 | +[GitHub]:https://github.com/ |
| 46 | +[Azure portal]: https://portal.azure.com/ |
0 commit comments