Skip to content

Instantly share code, notes, and snippets.

@Moishe
Last active November 11, 2020 19:25
Show Gist options
  • Save Moishe/e31097db3b8344d6108256105227c0de to your computer and use it in GitHub Desktop.
Save Moishe/e31097db3b8344d6108256105227c0de to your computer and use it in GitHub Desktop.
OAuth diff
5a6
> import json
9a11,13
> BASE_URL = "http://127.0.0.1:5000"
> OAUTH_CALLBACK = "{}/oauth/mailchimp/callback".format(BASE_URL)
>
28c32
< "redirect_uri": "OAUTH_CALLBACK"
---
> "redirect_uri": OAUTH_CALLBACK
40,43d43
< BASE_URL = "http://127.0.0.1:3000"
< OAUTH_CALLBACK = "{}/oauth/mailchimp/callback".format(BASE_URL)
<
< code = request.args['response_type']
44a45,46
> code = request.args['code']
> app.logger.info('requesting token using %s code' % code)
48,54c50,57
< 'body': {
< 'grant_type': 'authorization_code',
< 'client_id': MAILCHIMP_CLIENT_ID,
< 'client_secret': MAILCHIMP_CLIENT_SECRET,
< 'redirect_uri': OAUTH_CALLBACK,
< 'code': code
< }})
---
> 'grant_type': 'authorization_code',
> 'client_id': MAILCHIMP_CLIENT_ID,
> 'client_secret': MAILCHIMP_CLIENT_SECRET,
> 'redirect_uri': OAUTH_CALLBACK,
> 'code': code
> })
> app.logger.info('status_code: %s' % tokenResponse.status_code)
> app.logger.info('response: %s' % tokenResponse.json())
56d58
< print(access_token)
68c70
< print(dc)
---
> app.logger.info('dc: %s' % dc)
77,78c79,80
< "access_token": "YOUR_ACCESS_TOKEN",
< "server": "YOUR_SERVER_PREFIX"
---
> "access_token": access_token,
> "server": dc
82c84
< print(response)
---
> app.logger.info('Ping response: %s' % json.dumps(response))
98c100
< app.run(debug=True, host='0.0.0.0')
\ No newline at end of file
---
> app.run(debug=True, host='0.0.0.0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment