在谷歌文档中,它说
// 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().但它没有说明或展示如何做到这一点:(
有没有人知道如何在桌面应用中做到这一点?
代码示例非常受欢迎!
发布于 2012-05-14 00:50:18
好的,过了一段时间我解决了它。
在获得访问令牌之后,您还将获得刷新令牌。存储该令牌!
在发出下一个请求调用OAuthUtil.RefreshAccessToken(parameters);之前,还要执行此parameters.AccessToken = StoredRefreshToken和parameters.RefreshToken = StoredRefreshToken操作
然后你就可以很好地提出请求了!
发布于 2012-05-12 03:13:51
你用的是AuthSub with the .NET Client Library吗。如果是这样,试试这个
if (Request.QueryString["token"] != null)
{
String token = Request.QueryString["token"];
Session["token"] = AuthSubUtil.exchangeForSessionToken(token, null).ToString();
Response.Redirect(Request.Url.AbsolutePath, true);
}附言:上面的链接有完整的代码列表。
https://stackoverflow.com/questions/10556864
复制相似问题