【发布时间】:2020-09-16 04:51:49
【问题描述】:
我正在开发一个 Google Actions 应用程序和一个 Webhook,以使该应用程序与具有客户端凭据的服务器通信。使用我的服务器实现 OAuth 和 Google 登录流程时,我似乎无法找到 Google 端从 /token 端点等待的响应,它应该返回访问令牌,然后将在每个请求中使用该令牌由动作制成(..如果我正确理解了那部分..)。我目前返回一个带有适当状态码(我认为)的 ContentResult 和一个带有它应该返回的访问令牌的 json 正文。像这样的:
ContentResult result = null;
data.Add(@"token_type", @"Bearer");
data.Add(@"access_token", FAKE_ACCESS_TOKEN);
data.Add(@"refresh_token", FAKE_REFRESH_TOKEN);
data.Add(@"expires_in", FAKE_SECONDS_TO_EXPIRATION);
jsonResponse = data.ToString();
result = new ContentResult
{
Content = jsonResponse,
ContentType = "application/json"
StatusCode = (int?)HttpStatusCode.OK
};
return result;
这部分的Documentation 似乎含糊不清。也许有人可以帮我弄清楚吗?提前致谢
【问题讨论】:
-
这看起来不错。尝试
bearer而不是Bearer。Bearer在标头中发送令牌时应该是,但如果我没记错的话,OAuth2 身份提供者应该返回bearer。
标签: c# oauth-2.0 google-oauth actions-on-google