Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.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
Windows phone 7 WP7 C#检索Google OAuth 2.0请求的访问令牌_Windows Phone 7_C# 4.0_Google Oauth - Fatal编程技术网

Windows phone 7 WP7 C#检索Google OAuth 2.0请求的访问令牌

Windows phone 7 WP7 C#检索Google OAuth 2.0请求的访问令牌,windows-phone-7,c#-4.0,google-oauth,Windows Phone 7,C# 4.0,Google Oauth,我随后使用了GoogleOAuth2.0授权,但我不明白如何在我的应用程序中实现检索访问和刷新令牌的请求。正如该指南所说,该准则是当前的: // Request an access token OAuthAuthorization authorization = new OAuthAuthorization( "https://accounts.google.com/o/oauth2/auth", "https://accounts.google.com/o/oauth2/token")

我随后使用了GoogleOAuth2.0授权,但我不明白如何在我的应用程序中实现检索访问和刷新令牌的请求。正如该指南所说,该准则是当前的:

// Request an access token    
OAuthAuthorization authorization = new OAuthAuthorization(
"https://accounts.google.com/o/oauth2/auth",
"https://accounts.google.com/o/oauth2/token");
TokenPair tokenPair = await authorization.Authorize(
        ClientId,
        ClientSecret,
        new string[] {GoogleScopes.CloudPrint, GoogleScopes.Gmail});


// Request a new access token using the refresh token (when the access token was expired)
TokenPair refreshTokenPair = await authorization.RefreshAccessToken(
        ClientId,
        ClientSecret,
        tokenPair.RefreshToken);
在通用Windows Phone应用程序中,在何处以及如何调用此函数


(很抱歉,如果有这个问题,它是重复的,但我尝试搜索,我只找到通用谷歌API指南的答案链接)

您可以在必要时调用它(当您需要获得令牌时)。之后,使用官方Google库访问API,并从TokenPair向他们提供数据。另外,记住在你的项目中使用这个(),这样你就可以使用Google Scopes了。

Mmm,我试图用PCL的官方Dotnet库编译我的Youtube应用程序,但每次启动时都无法运行……我不知道是Windows Phone 7出现问题还是其他原因。。。