firemail

标题: gmail/imap [打印本页]

作者: Qter    时间: 2020-7-22 15:35
标题: gmail/imap
本帖最后由 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.
复制代码


作者: Qter    时间: 2020-7-22 19:11
本帖最后由 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

作者: Qter    时间: 2020-7-22 19:37
google login api 申请 CLIENT_SECRET 和 CLIENT_SECRET
https://blog.csdn.net/terry_water/article/details/55095209






欢迎光临 firemail (http://firemail.wang:8088/) Powered by Discuz! X3