Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何获取长期访问令牌GoogleAPI_C#_Winforms_.net 4.0_Google Docs Api_Google Data Api - Fatal编程技术网

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应用的,我正在制作一个桌面应用。