Догађаји
Поwер БИ ДатаВиз Светско првенство
14. феб 16 - 31. мар 16
Са 4 шансе за улазак, можете освојити конференцијски пакет и стићи до ЛИВЕ Гранд Финале у Лас Вегасу
Сазнајте вишеОвај прегледач више није подржан.
Надоградите на Microsoft Edge бисте искористили најновије функције, безбедносне исправке и техничку подршку.
By Valeriy Novytskyy, Rick Anderson and Sharaf Abacery
This tutorial shows you how to enable users to sign in with their Google account using the ASP.NET Core project created on the previous page.
Follow the guidance in Integrating Google Sign-In into your web app (Google documentation)
Go to Google API & Services.
A Project must exist first, you may have to create one. Once a project is selected, enter the Dashboard.
In the Oauth consent screen of the Dashboard:
In the Credentials tab of the application Dashboard, select CREATE CREDENTIALS > OAuth client ID.
Select Application type > Web application, choose a name.
In the Authorized redirect URIs section, select ADD URI to set the redirect URI. Example redirect URI: https://localhost:{PORT}/signin-google
, where the {PORT}
placeholder is the app's port.
Select the CREATE button.
Save the Client ID and Client Secret for use in the app's configuration.
When deploying the site, either:
Store sensitive settings such as the Google client ID and secret values with Secret Manager. For this sample, use the following steps:
Initialize the project for secret storage per the instructions at Enable secret storage.
Store the sensitive settings in the local secret store with the secret keys Authentication:Google:ClientId
and Authentication:Google:ClientSecret
:
dotnet user-secrets set "Authentication:Google:ClientId" "<client-id>"
dotnet user-secrets set "Authentication:Google:ClientSecret" "<client-secret>"
The :
separator doesn't work with environment variable hierarchical keys on all platforms. For example, the :
separator is not supported by Bash. The double underscore, __
, is:
:
.You can manage your API credentials and usage in the API Console.
Google.Apis.Auth.AspNetCore3
NuGet package to the app.program.cs
:Add Authtication for asp.net app
The call to AddIdentity configures the default scheme settings. The AddAuthentication(IServiceCollection, String) overload sets the DefaultScheme property. The AddAuthentication(IServiceCollection, Action<AuthenticationOptions>) overload allows configuring authentication options, which can be used to set up default authentication schemes for different purposes. Subsequent calls to AddAuthentication
override previously configured AuthenticationOptions properties.
AuthenticationBuilder extension methods that register an authentication handler may only be called once per authentication scheme. Overloads exist that allow configuring the scheme properties, scheme name, and display name.
data-login_uri="{HostName}/{ControllerName}/{actionName}"
attrbute because after success login it will forward you to that link.string credential
, which is returned by Google upon completing the login process.credential
using the following line of code:
GoogleJsonWebSignature.Payload payload = await GoogleJsonWebSignature.ValidateAsync(credential);
The URI segment /signin-google
is set as the default callback of the Google authentication provider. You can change the default callback URI while configuring the Google authentication middleware via the inherited RemoteAuthenticationOptions.CallbackPath property of the GoogleOptions class.
services.AddIdentity
in ConfigureServices
, attempting to authenticate results in ArgumentException: The 'SignInScheme' option must be provided. The project template used in this tutorial ensures Identity is configured.ClientSecret
in the Google API Console.Authentication:Google:ClientId
and Authentication:Google:ClientSecret
as application settings in the Azure portal. The configuration system is set up to read keys from environment variables.ASP.NET Core повратне информације
ASP.NET Core је пројекат отвореног кода. Изаберите везу да бисте обезбедили повратне информације:
Догађаји
Поwер БИ ДатаВиз Светско првенство
14. феб 16 - 31. мар 16
Са 4 шансе за улазак, можете освојити конференцијски пакет и стићи до ЛИВЕ Гранд Финале у Лас Вегасу
Сазнајте вишеОбука
Модул
Discover how Microsoft Entra External ID can provide secure, seamless sign-in experiences for your consumers and business customers. Explore tenant creation, app registration, flow customization, and account security.
Цертификација
Microsoft Certified: Identity and Access Administrator Associate - Certifications
Demonstrate the features of Microsoft Entra ID to modernize identity solutions, implement hybrid solutions, and implement identity governance.
Документација
Using external login providers with Identity in ASP.NET Core
Create an ASP.NET Core app using Identity with external authentication providers such as Facebook, Twitter, Google, and Microsoft.
Microsoft Account external login setup with ASP.NET Core
This sample demonstrates the integration of Microsoft account user authentication into an existing ASP.NET Core app.
Facebook, Google, and external provider authentication without ASP.NET Core Identity
Use Facebook, Google, Twitter, etc. account user authentication without ASP.NET Core Identity.