Google OAuth API で認証に成功しました。初めて正しく動作します。同じものに 2 回目にアクセスすると、次のエラーが発生します。
「ダイレクト メッセージの送信中または応答の取得中にエラーが発生しました。」
スタックトレース:
[WebException: The remote server returned an error: (400) Bad Request.]
System.Net.HttpWebRequest.GetResponse() +6038435
DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions options) +410
[ProtocolException: Error occurred while sending a direct message or getting the response.]
DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request, DirectWebRequestOptions options) +1618
DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request) +73
DotNetOpenAuth.Messaging.Channel.GetDirectResponse(HttpWebRequest webRequest) +82
DotNetOpenAuth.Messaging.Channel.RequestCore(IDirectedProtocolMessage request) +357
DotNetOpenAuth.Messaging.Channel.Request(IDirectedProtocolMessage requestMessage) +158
DotNetOpenAuth.OAuth2.ClientBase.UpdateAuthorizationWithResponse(IAuthorizationState authorizationState, EndUserAuthorizationSuccessAuthCodeResponse authorizationSuccess) +319
DotNetOpenAuth.OAuth2.WebServerClient.ProcessUserAuthorization(HttpRequestInfo request) +885
メソッドの
private IAuthorizationState GetAuthorization(WebServerClient client)
{
String accesstoken = "";
IAuthorizationState state = AuthState;
if (state != null)
{
return state;
}
state = client.ProcessUserAuthorization(new HttpRequestInfo(HttpContext.Current.Request));
if (state != null && (!string.IsNullOrEmpty(state.AccessToken)
|| !string.IsNullOrEmpty(state.RefreshToken)))
{
accesstoken = state.AccessToken;
HttpContext.Current.Session["AUTH_STATE"] = _state = state;
return null;
}
string scope = TasksService.Scopes.TasksReadonly.GetStringValue();
OutgoingWebResponse response = client.PrepareRequestUserAuthorization(new[] {
scope,
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email"
});
response.Send();
return null;
}
private IAuthorizationState AuthState
{
get
{
return _state ?? HttpContext.Current.Session["AUTH_STATE"] as IAuthorizationState;
}
}
ラインで
state = client.ProcessUserAuthorization(new HttpRequestInfo(HttpContext.Current.Request));
貴重な回答とコメントを待っています