2016-07-19 10 views
0

ASP.NETセキュリティ社会サンプルhas two ways to interact with Google.UseOAuthAuthenticationとUseGoogleAuthenticationの背後にあるプロトコルの標準名は何ですか?

UseOAuthAuthentication

app.UseOAuthAuthentication(new OAuthOptions 
{ 
    AuthenticationScheme = "Google-AccessToken", 
    DisplayName = "Google-AccessToken", 
    ClientId = Configuration["google:clientid"], 
    ClientSecret = Configuration["google:clientsecret"], 
    CallbackPath = new PathString("/signin-google-token"), 
    AuthorizationEndpoint = GoogleDefaults.AuthorizationEndpoint, 
    TokenEndpoint = GoogleDefaults.TokenEndpoint, 
    Scope = { "openid", "profile", "email" }, 
    SaveTokens = true 
}); 

UseGoogleAuthentication

app.UseGoogleAuthentication(new GoogleOptions 
{ 
    ClientId = Configuration["google:clientid"], 
    ClientSecret = Configuration["google:clientsecret"], 
    SaveTokens = true, 
    Events = new OAuthEvents() 
    { 
     OnRemoteFailure = ctx => 
     { 
      ctx.Response.Redirect("/error?FailureMessage=" 
       + UrlEncoder.Default.Encode(ctx.Failure.Message)); 
      ctx.HandleResponse(); 
      return Task.FromResult(0); 
     } 
    } 
}); 

認証および承認のこれら2つのタイプの標準的な名前は何ですか?I。 1つはOAuthで、もう1つはOpenID Connectですか?

UseOAuthAuthenticationを選択すると、これが原因です。

context 
    .User.Claims: [] 
    .User.Identity.Name: null 
    .Authentication.GetTokenAsync("access_token"): ya29.CjAlAz3AcUnRD... 
    .Authentication.GetTokenAsync("refresh_token"): null 
    .Authentication.GetTokenAsync("token_type"): Bearer 
    .Authentication.GetTokenAsync("expires_at"): 2016-07-19T22:49:54... 

UseGoogleAuthenticationを選択すると、これが原因です。

context 
    .User.Claims: [ 
     nameidentifier: 10424487944... 
     givenname: Shaun 
     surname: Luttin 
     name: Shaun Luttin 
     emailaddress: [email protected] 
     profile: https://plus.google.com/+ShaunLuttin   
    ] 
    .User.Identity.Name: "Shaun Luttin" 
    .Authentication.GetTokenAsync("access_token"): ya29.CjAlAz3AcUnRD... 
    .Authentication.GetTokenAsync("refresh_token"): null 
    .Authentication.GetTokenAsync("token_type"): Bearer 
    .Authentication.GetTokenAsync("expires_at"): 2016-07-19T22:49:54... 

答えて

0

両方UseOAuthAuthenticationUseGoogleAuthenticationはOAuthのです。違いは、Googleのミドルウェアは、Googleに固有のいくつかのデフォルトのOAuthオプションを設定し、ユーザプロファイル情報を取得するGoogleHandlerを追加することです。すなわち

  • UseOAuthAuthenticationを取得OAuthのアクセストークンです。

  • UseGoogleAuthenticationはオプションでOAuthであり、Googleからアクセスコードとユーザープロフィール情報を取得するために調整されています。

関連する問題