【发布时间】:2018-07-24 08:26:19
【问题描述】:
在 UWP 应用中,我首先使用以下端点获取刷新令牌和访问令牌:
string tokenRequestBody = string.Format("code={0}&redirect_uri={1}&client_id={2}&scope=&grant_type=authorization_code",
code,
System.Uri.EscapeDataString(redirectURI),
clientID
);
StringContent content = new StringContent(tokenRequestBody, Encoding.UTF8, "application/x-www-form-urlencoded");
HttpResponseMessage response = new HttpClient().PostAsync("https://www.googleapis.com/oauth2/v4/token", content).Result;
在响应的这一点上,我有一个刷新令牌和一个功能齐全的 1 小时访问令牌。这工作正常。
现在我想使用刷新令牌来更新访问令牌:
string tokenRequestBody = string.Format("client_id={0}&refresh_token={1}&grant_type=refresh_token", clientID, _refreshToken);
StringContent body = new StringContent(tokenRequestBody, Encoding.UTF8, "application/x-www-form-urlencoded");
HttpResponseMessage tokenResponse = new HttpClient().PostAsync("https://www.googleapis.com/oauth2/v4/token", body).Result;
我没有获得新的访问令牌,而是出现以下错误:
[{"domain":"usageLimits","reason":"dailyLimitExceededUnreg","message":"Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.","extendedHelp":"https://code.google.com/apis/console"}],"code":403,"message":"Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."}
我在这里错过了什么?
感谢您的帮助。
【问题讨论】:
-
您要使用什么 Google API 服务?
-
Google 云端硬盘 API。
标签: c# google-api uwp google-oauth