1

我开发了一个用于 Google 日历集成的应用程序。我在使用日历服务时卡在一个地方。请检查下面的代码。

private static IAuthorizationState GetAuthorization(NativeApplicationClient arg, String Refreshtoken)
{                    
    IAuthorizationState state = new AuthorizationState(new[] { CalendarService.Scopes.Calendar.GetStringValue() });
    state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
    state.RefreshToken = Refreshtoken;
    try
    {
        if (arg.RefreshToken(state))     // This is calling out to the OAuth servers with the refresh token getting back a session token, returns true if successful.
        {
            if (state.RefreshToken != Refreshtoken) // if the refresh token has changed, save it.
            {
              //save token
            }
            return state; // Retain the authorization state, this is what will authenticate your calls.
        }
    }
    catch (Exception ex)
    {

    }
    return state;
}

我得到的例外是

Exception:
at DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request,         
DirectWebRequestOptions options) at 
DotNetOpenAuth.Messaging.StandardWebRequestHandler.GetResponse(HttpWebRequest request) at 
DotNetOpenAuth.Messaging.Channel.GetDirectResponse(HttpWebRequest webRequest) at 
DotNetOpenAuth.Messaging.Channel.RequestCore(IDirectedProtocolMessage request) at     
DotNetOpenAuth.Messaging.Channel.Request(IDirectedProtocolMessage requestMessage) at 
DotNetOpenAuth.Messaging.Channel.Request[TResponse](IDirectedProtocolMessage requestMessage) at 
DotNetOpenAuth.OAuth2.ClientBase.RefreshToken(IAuthorizationState authorization, Nullable`1 
skipIfUsefulLifeExceeds) at GoogleCalendarProvider_V3.GetAuthorization(NativeApplicationClient 
arg, String Refreshtoken)

Exception Message:
Error occurred while sending a direct message or getting the response. 
4

0 回答 0