Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1149|回复: 2
打印 上一主题 下一主题

gmail/imap

[复制链接]

1228

主题

1997

帖子

7582

积分

认证用户组

Rank: 5Rank: 5

积分
7582
跳转到指定楼层
楼主
发表于 2020-7-22 15:35:13 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 Qter 于 2020-8-3 14:34 编辑

https://developers.google.com/gmail/imap

OAuth2DotPyRunThrough

https://github.com/google/gmail-oauth2-tools/wiki/OAuth2DotPyRunThrough

Access tokens expire after one hour. Typically an application will save the refresh token permanently, and generate new access tokens as needed. oauth2.py can issue a new access token from a valid refresh token.


  1. Refreshing an access token
  2. Access tokens periodically expire and become invalid credentials for a related API request. You can refresh an access token without prompting the user for permission (including when the user is not present) if you requested offline access to the scopes associated with the token.

  3. To refresh an access token, your application sends an HTTPS POST request to Google's authorization server (https://oauth2.googleapis.com/token) that includes the following parameters:

  4. Fields
  5. client_id        The client ID obtained from the API Console.
  6. client_secret        The client secret obtained from the API Console. (The client_secret is not applicable to requests from clients registered as Android, iOS, or Chrome applications.)
  7. grant_type        As defined in the OAuth 2.0 specification, this field must contain a value of refresh_token.
  8. refresh_token        The refresh token returned from the authorization code exchange.
  9. The following snippet shows a sample request:

  10. POST /token HTTP/1.1
  11. Host: oauth2.googleapis.com
  12. Content-Type: application/x-www-form-urlencoded

  13. client_id=your_client_id&
  14. client_secret=your_client_secret&
  15. refresh_token=refresh_token&
  16. grant_type=refresh_token

  17. As long as the user has not revoked the access granted to the application, the token server returns a JSON object that contains a new access token. The following snippet shows a sample response:

  18. {
  19.   "access_token": "1/fFAGRNJru1FTz70BzhT3Zg",
  20.   "expires_in": 3920,
  21.   "scope": "https://www.googleapis.com/auth/drive.metadata.readonly",
  22.   "token_type": "Bearer"
  23. }

  24. Note that there are limits on the number of refresh tokens that will be issued; one limit per client/user combination, and another per user across all clients. You should save refresh tokens in long-term storage and continue to use them as long as they remain valid. If your application requests too many refresh tokens, it may run into these limits, in which case older refresh tokens will stop working.
复制代码

回复

使用道具 举报

1228

主题

1997

帖子

7582

积分

认证用户组

Rank: 5Rank: 5

积分
7582
沙发
 楼主| 发表于 2020-7-22 19:11:27 | 只看该作者
本帖最后由 Qter 于 2020-7-22 19:45 编辑

https://appuals.com/fix-your-ima ... nvalid-credentials/

imap_response = 0x0011a320 "Invalid credentials (Failure)"
error_code = 1
https://stackoverflow.com/questions/29305068/mailcore-wont-login-to-gmail-mailcore-code-19-unknown-error-code
回复 支持 反对

使用道具 举报

1228

主题

1997

帖子

7582

积分

认证用户组

Rank: 5Rank: 5

积分
7582
板凳
 楼主| 发表于 2020-7-22 19:37:39 | 只看该作者
google login api 申请 CLIENT_SECRET 和 CLIENT_SECRET
https://blog.csdn.net/terry_water/article/details/55095209

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|firemail ( 粤ICP备15085507号-1 )

GMT+8, 2024-5-1 16:12 , Processed in 0.062768 second(s), 18 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表