C# 如何获取长期访问令牌GoogleAPI
在谷歌的文档中,它说C# 如何获取长期访问令牌GoogleAPI,c#,winforms,.net-4.0,google-docs-api,google-data-api,C#,Winforms,.net 4.0,Google Docs Api,Google Data Api,在谷歌的文档中,它说 // Once the user authorizes with Google, the request token can be exchanged // for a long-lived access token. If you are building a browser-based // application, you should parse the incoming request token from the url and // set it in OA
// Once the user authorizes with Google, the request token can be exchanged
// for a long-lived access token. If you are building a browser-based
// application, you should parse the incoming request token from the url and
// set it in OAuthParameters before calling GetAccessToken().
但它并没有说明或显示如何做到这一点:(
有人知道如何为桌面应用程序做到这一点吗
非常欢迎使用代码示例!您正在使用。如果是,请尝试此选项
if (Request.QueryString["token"] != null)
{
String token = Request.QueryString["token"];
Session["token"] = AuthSubUtil.exchangeForSessionToken(token, null).ToString();
Response.Redirect(Request.Url.AbsolutePath, true);
}
注:上面的链接有完整的代码列表。好的,过了一段时间我解决了它 获得访问令牌后,还将获得刷新令牌。请存储该令牌 也可以这样做
parameters.AccessToken=storedrefreshtToken
和parameters.refreshtToken=storedrefreshtToken
在发出下一个请求之前,请调用OAuthUtil.RefreshAccessToken(参数);
然后你就可以提出请求了!我得到了“尝试升级不可升级的令牌”,这是针对web应用的,我正在制作一个桌面应用。