Google/Facebookへの外部ログインにOWINを使用しようとしています。C#Owinの応答タイプをコードからトークンに変更してください
問題は、owinチャレンジが応答タイプをトークンからコードに変更し続けることに直面しています。これは、Googleからのエラーを返し https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=client_dim&redirect_uri=mywebsite.com&scope=scope&state=state
:
課題は、以下のURLを生成します。私がresponse_typeをtoken(response_type = token)に変更すると動作します。
ここでのOAuthオプション
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/Token"),
Provider = new ApplicationOAuthProvider(PublicClientId),
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
// In production mode set AllowInsecureHttp = false
AllowInsecureHttp = true,
};
Googleのミドルウェアの設定されています
app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
{
ClientId = "clientid",
ClientSecret = "client secret",
});
ここでは、チャレンジです:
var properties = new AuthenticationProperties() { AllowRefresh = true, RedirectUri="mywebsite.co.za" };
Request.GetOwinContext().Authentication.Challenge(properties,LoginProvider);
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Unauthorized);
response.RequestMessage = Request;
return Task.FromResult(response);
OWINは、一般的なMVCのAPIからの基本的な設定ですプロジェクト。