无法使用 google OAuth 2 获取刷新令牌

Unable to get refresh token with google OAuth 2

情况

我有一个简单的 android 应用程序,用户可以在其中从 Google Fusion Tables with REST api. For this I was using OAuth 2 authorization to get Access Token and Refresh Token. I have web view in my app which will show login screen as well as consent screen. I was planning to get access token from web view and use it for further API calls. I am using retrofit 获取数据来执行我的 http 调用。我使用以下查询参数,

"client_id" = CLIENTID
"client_secret" = SECRET
"code" = 4/XXXXXXXXXX  //Code got from redirect url
"grant_type" = "authorization_code"  
"access_type" = "offline"
"approval_prompt" = "force"
"redirect_uri" = REDIRECT_URL

到目前为止一切顺利。但是当我使用上述查询参数执行 post 请求时,我得到以下响应

{
  "access_token": "ya29.XXXXXXXXXXXXXX",
  "token_type": "Bearer",
  "expires_in": 3599,
  "id_token": "XXXXXXXXXX"
}

问题

刷新令牌在哪里?我需要刷新令牌,因为稍后我无法使用访问令牌通过应用程序进行 API 调用,而且我不希望用户每次都获得访问令牌。

我试过的

我已经按照 this post 的说明进行操作,并尝试从设置中撤销对应用程序的许可。我也尝试过使用不同的 google 帐户以防出现权限问题,但仍然没有成功。我也尝试删除查询参数 "approval_prompt" 和 "grant_type" 但这也没有帮助。

无需在授权请求中指定 grant_type=offline,您需要提供 access_type=offline 来请求刷新令牌。

我在搜索和敲头 5-6 小时后得到了答案。 This 回答救了我!对将来寻找此内容的人的回答,

添加 "access_type" = "offline" 查询,同时 请求 访问令牌而不是 交换 ,即在 URL 征求同意。