Advertisement
Guest User

Untitled

a guest
Jan 9th, 2018
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. from requests_oauthlib import OAuth2Session
  2.  
  3. class ClientSecrets:
  4. client_id = "ewdwadawdawdwa"
  5. client_secret = "hjukjyuuyjyujyuujyjuyjujy"
  6. redirect_uris = [
  7. "https://api.bitbucket.org/2.0/repositories/Ty/more/downloads" # Used for testing.
  8. ]
  9. auth_uri = "https://bitbucket.org/site/oauth2/authorize"
  10. token_uri = "https://bitbucket.org/site/oauth2/access_token"
  11. server_base_uri = "https://api.bitbucket.org/2.0/repositories/Ty/more/downloads"
  12.  
  13.  
  14. def main():
  15. c = ClientSecrets()
  16. # Fetch a request token
  17. bitbucket = OAuth2Session(c.client_id)
  18. # Redirect user to Bitbucket for authorization
  19. authorization_url = bitbucket.authorization_url(c.auth_uri)
  20. print('Please go here and authorize: {}'.format(authorization_url[0]))
  21. # Get the authorization verifier code from the callback url
  22. redirect_response = input('https://api.bitbucket.org/2.0/repositories/Tysondogerz/more/downloads: https://api.bitbucket.org/2.0/repositories/Tysondogerz/more/downloads')
  23. redirect_response = raw_input('Paste the full redirect URL here:') ########Stops here #########################
  24. # Fetch the access token
  25. bitbucket.fetch_token(
  26. c.token_uri,
  27. authorization_response=redirect_response,
  28. username=c.client_id,
  29. password=c.client_secret)
  30. # Fetch a protected resource, i.e. user profile
  31. r = bitbucket.get(c.server_base_uri + '1.0/user')
  32. print(r.content)
  33. print('hi')
  34.  
  35. if __name__ == '__main__':
  36. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement