แก้ไข

แชร์ผ่าน


Configure your App Service or Azure Functions app to use Google login

This topic shows you how to configure Azure App Service or Azure Functions to use Google as an authentication provider.

To complete the procedure in this topic, you must have a Google account that has a verified email address. To create a new Google account, go to accounts.google.com.

Register your application with Google

  1. Follow the Google documentation at Sign In with Google for Web - Setup to create a client ID and client secret. There's no need to make any code changes. Just use the following information:

    • For Authorized JavaScript Origins, use https://<app-name>.azurewebsites.net with the name of your app in <app-name>.
    • For Authorized Redirect URI, use https://<app-name>.azurewebsites.net/.auth/login/google/callback.
  2. Copy the App ID and the App secret values.

    Important

    The App secret is an important security credential. Do not share this secret with anyone or distribute it within a client application.

Add Google information to your application

  1. Sign in to the Azure portal and navigate to your app.

  2. Select Authentication in the menu on the left. Click Add identity provider.

  3. Select Google in the identity provider dropdown. Paste in the App ID and App Secret values that you obtained previously.

    The secret will be stored as a slot-sticky application setting named GOOGLE_PROVIDER_AUTHENTICATION_SECRET. You can update that setting later to use Key Vault references if you wish to manage the secret in Azure Key Vault.

  4. 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.

    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.

  5. Click Add.

Note

For adding scope: You can define what permissions your application has in the provider's registration portal. The app can request scopes at login time which leverage these permissions.

You are now ready to use Google for authentication in your app. The provider will be listed on the Authentication screen. From there, you can edit or delete this provider configuration.

Next steps