ASP.Net MVC 5 Google-Authentifizierung mit Rahmen

Ich versuche zu bekommen ASP.Net MVC 5 Google OAuth2-Authentifizierung korrekt funktioniert.

Wenn ich den pass in einer GoogleOauth2AuthenticationOptions ohne Rahmen, dann bin ich in der Lage, log-in erfolgreich.

var googlePlusOptions = new GoogleOAuth2AuthenticationOptions
{
    ClientId = googleClientId,
    ClientSecret = googleClientSecret,
    SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie,
    Provider = new GoogleOAuth2AuthenticationProvider()
    {
        OnAuthenticated = async ctx =>
        {
            ctx.Identity.AddClaim(new Claim("urn:tokens:googleplus:accesstoken", ctx.AccessToken));
        }
    },
};

app.UseGoogleAuthentication(googlePlusOptions);

Dann dieser Anruf zurück ExternalLoginInfo-Objekt mit allen Eigenschaften

ExternalLoginInfo loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();

Wenn ich hinzufügen Geltungsbereich wenn, dann ich bekomme keine login-info zurückgegeben. Es ist einfach null.

var googlePlusOptions = new GoogleOAuth2AuthenticationOptions
{
    ClientId = googleClientId,
    ClientSecret = googleClientSecret,
    SignInAsAuthenticationType = DefaultAuthenticationTypes.ExternalCookie,
    Provider = new GoogleOAuth2AuthenticationProvider()
    {
        OnAuthenticated = async ctx =>
        {
            ctx.Identity.AddClaim(new Claim("urn:tokens:googleplus:accesstoken", ctx.AccessToken));
        }
    },
};

googlePlusOptions.Scope.Add(YouTubeService.Scope.Youtube);

app.UseGoogleAuthentication(googlePlusOptions);

Dann wird der Anruf auf externe Informationen nur gibt null zurück,.

ExternalLoginInfo loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();

In den Google dev console, ich habe die folgenden APIs eingeschaltet..

  • Analytics-API
  • BigQuery API
  • Google Cloud SQL
  • Google Cloud Storage
  • Google Cloud Storage-JSON-API
  • Google+ API
  • Google+ Domains API
  • Identity Toolkit API
  • YouTube Analytics API
  • YouTube Data API v3

Etwas über das hinzufügen von Rahmen, um die Optionen zu brechen GetExternalLoginInfoAsync.

InformationsquelleAutor Rob Gibbens | 2014-03-27
Schreibe einen Kommentar