google-api - Google OAuth2 中缺少 refresh_token .Net HttpPost 对 access_token 的请求

标签 google-api google-oauth access-token google-api-dotnet-client refresh-token

在我使用 .Net HttpPost 的 Google OAuth 请求中,refresh_token 值丢失。

引用:https://developers.google.com/identity/protocols/oauth2/web-server#exchange-authorization-code enter image description here

我输入的 HTTP post 请求 -

...google oauth post request details..url - (https://accounts.google.com/o/oauth2/token)...
and the postData - (client_id=<client_id>&client_secret=<client_secret_key>&grant_type=authorization_code&redirect_uri=<redirect_url>&code=<authorization_code>&access_type=offline&prompt=consent&approval_prompt=force)

注意:我有一个带有 access_token 的有效响应。但是,refresh_token 对象值为空记录。

请帮忙。

我已经查看了这些链接 - Not receiving Google OAuth refresh token

最佳答案

为访问 token 和刷新 token 交换授权代码的调用如下所示。

HTTP POST https://accounts.google.com/o/oauth2/token
code=4/X9lG6uWd8-MMJPElWggHZRzyFKtp.QubAT_P-GEwePvB8fYmgkJzntDnaiAI&client_id={ClientId}&client_secret={ClientSecret}&redirect_uri={redirectURI}&grant_type=authorization_code

您不使用 access_type 、approval_prompt、prompt 作为授权代码交换的一部分,它们包含在显示同意屏幕的 HTTP GET 请求中。

如果您已经在 google 开发者控制台上创建了网络凭证客户端,您可以在此处添加 access_type。

HTTP GET https://accounts.google.com/o/oauth2/auth?client_id={clientid}&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https://www.googleapis.com/auth/analytics.readonly&response_type=code&access_type=offline

如果您有兴趣了解调用是如何建立的,这可能会有所帮助。 Understanding Google OAuth 2.0 with curl

关于google-api - Google OAuth2 中缺少 refresh_token .Net HttpPost 对 access_token 的请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69747758/

相关文章:

android - 谷歌地图 API key 在侧面加载时适用于发布版本,在发布时不起作用

google-analytics - Google Analytics API 返回 "Quota Error: User Rate Limit Exceeded."而只有几千个查询

javascript - 未捕获的安全错误 : Blocked a frame with origin "https://www.google.com" from accessing a frame with origin "http://my.site.com".

reactjs - 当我未通过 NextAuth Google 提供商的登录规则时,无法更改帐户

python - 访问 token 更改时获取请求

php - 清理 Magento Google Api OAuth2 集成

java - 如何在 java 中使用 refreshtoken 在 Youtube 中上传视频

ios - 4 月份 google/gtm-oauth2/GTMOAuth2ViewControllerTouch 将如何运作?

c# - Outlook Exchange 办公室 365 : How to get email address from access token?

laravel - 存储外部访问/刷新 token