刷新令牌到期时间谷歌日历 [英] Refresh Token Expiration time Google calendar

查看:355
本文介绍了刷新令牌到期时间谷歌日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何一个可以告诉我的到期时间刷新令牌生成的OAuth2通过。实际上,它通常返回2参数访问令牌和刷新令牌。我们使用刷新令牌,以生成新托克的访问,如果访问令牌得到过期。不过,谷歌日历版本3,我使用,以调用API,日历更新凭证。但在这里我得到令牌获取过期的问题。因此,任何一个可以请建议我,当令牌获取到期我能做些什么。据我没有到期时间刷新令牌。使用刷新令牌请检查下面的code创造日历服务 -

 私人CalendarService的CreateService(字符串标记)
{
    KeyValuePair<字符串,字符串>凭据= Common.Get3LOCredentials();
    VAR提供商=新NativeApplicationClient(GoogleAuthenticationServer.Description);
    provider.ClientIdentifier = credentials.Key;
    provider.ClientSecret = credentials.Value;
    变种AUTH =新Google.Apis.Authentication.OAuth2.OAuth2Authenticator&所述; NativeApplicationClient>(提供商(P)=> GetAuthorization(提供商,令牌));
    CalendarService服务=新CalendarService(新BaseClientService.Initializer()
    {
        身份验证= AUTH,
        ApiKey = ConfigurationManager.AppSettings [APIkey]。的ToString()
        GZipEnabled = FALSE
    });
    退换货服务;
}私有静态IAuthorizationState GetAuthorization(NativeApplicationClient阿根廷,字符串Refreshtoken)
{
    IAuthorizationState状态=新AuthorizationState(新[] {CalendarService.Scopes.Calendar.GetStringValue()});
    state.Callback =新的URI(NativeApplicationClient.OutOfBandCallbackUrl);
    state.RefreshToken = Refreshtoken;
    返回状态;
}


解决方案

刷新令牌不会过期,但它们可以被撤销。你的标记处理程序可以撤销自己编程的令牌或最终用户可以通过< A HREF =htt​​ps://support.google.com/accounts/answer/41236?hl=en相对=nofollow>撤销令牌帐户设置。请确保您正确地使用刷新令牌获取新的访问令牌你又不是试图使用已过期的访问令牌。

您可以编辑你的问题,以显示你所得到的确切的错误?

Can any one please tell me the expiration time for Refresh token generation through OAuth2. Actually it usually returns 2 parameter access token and refresh token. We used refresh token in order to generate a new access toke if access token get expired. But Google Calendar Version3, i am using refresh token in order to call the calendar API. But here i am getting a problem that token get expires. So can any one please suggest me what can i do when token get expires. According to me there is no expiration time for refresh token. Kindly check the code below for creation of calendar service using refresh token :-

 private CalendarService CreateService(string token)
{        
    KeyValuePair<string, string> credentials = Common.Get3LOCredentials();
    var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
    provider.ClientIdentifier = credentials.Key;
    provider.ClientSecret = credentials.Value;
    var auth = new Google.Apis.Authentication.OAuth2.OAuth2Authenticator<NativeApplicationClient>(provider, (p) => GetAuthorization(provider, token));
    CalendarService service = new CalendarService(new BaseClientService.Initializer()
    {
        Authenticator = auth,
        ApiKey = ConfigurationManager.AppSettings["APIkey"].ToString(),
        GZipEnabled = false
    });       
    return service;
}

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;        
    return state;
}

解决方案

Refresh Tokens do not expire but they can be revoked. You, the token handler can revoke the token yourself programatically or the end user can revoke the token in their account settings. Make sure you are properly using the refresh token to get a new access token and you're not attempting to use an access token that has expired.

Can you edit your question to show the exact error you are getting?

这篇关于刷新令牌到期时间谷歌日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆