Advertisement
Guest User

problems

a guest
Feb 4th, 2020
332
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. NOTE: Preferable, paste this in a markdown editor and view. Will be easier to read.
  2.  
  3. token created from SxGDriveTokenGenerator
  4. ```python
  5. {
  6. "access_token": "...",
  7. "client_id": "...",
  8. "client_secret": "...",
  9. "refresh_token": "...",
  10. "token_expiry": "2020-02-05T05:15:49Z",
  11. "token_uri": "https://oauth2.googleapis.com/token",
  12. "user_agent": null,
  13. "revoke_uri": "https://oauth2.googleapis.com/revoke",
  14. "id_token": null,
  15. "id_token_jwt": null,
  16. "token_response": {
  17. "access_token": "...",
  18. "expires_in": 3599,
  19. "refresh_token": "...",
  20. "scope": "https://www.googleapis.com/auth/drive.readonly",
  21. "token_type": "Bearer"
  22. },
  23. "scopes": [
  24. "https://www.googleapis.com/auth/drive.readonly"
  25. ],
  26. "token_info_uri": "https://oauth2.googleapis.com/tokeninfo",
  27. "invalid": false,
  28. "_class": "OAuth2Credentials",
  29. "_module": "oauth2client.client"
  30. }
  31. ```
  32.  
  33. According to this code snippet from nut's latest source
  34. ```python
  35. def getGdriveToken(request, response):
  36. creds = None
  37.  
  38. if os.path.exists('token.pickle'):
  39. with open('token.pickle', 'rb') as token:
  40. creds = pickle.load(token)
  41.  
  42. if not creds or not creds.valid:
  43. if creds and creds.expired and creds.refresh_token:
  44. creds.refresh(Request())
  45. else:
  46. flow = InstalledAppFlow.from_client_secrets_file(
  47. Config.getGdriveCredentialsFile(), SCOPES)
  48. creds = flow.run_local_server(port=0)
  49.  
  50. with open('token.pickle', 'wb') as token:
  51. pickle.dump(creds, token)
  52.  
  53. r = {}
  54. r['access_token'] = creds.token
  55. r['refresh_token'] = creds.refresh_token
  56.  
  57. with open(Config.getGdriveCredentialsFile(), 'r') as f:
  58. r['credentials'] = json.loads(f.read())
  59.  
  60.  
  61. response.write(json.dumps(r))
  62. ```
  63.  
  64. tinfoil accepts token in the following format
  65. ```python
  66. {
  67. "access_token": <token>,
  68. "refresh_token": <refresh_token>,
  69. "credentials": <credentials>
  70. }
  71. ```
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement