Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from requests_oauthlib import OAuth2Session
- class ClientSecrets:
- client_id = "ewdwadawdawdwa"
- client_secret = "hjukjyuuyjyujyuujyjuyjujy"
- redirect_uris = [
- "https://api.bitbucket.org/2.0/repositories/Ty/more/downloads" # Used for testing.
- ]
- auth_uri = "https://bitbucket.org/site/oauth2/authorize"
- token_uri = "https://bitbucket.org/site/oauth2/access_token"
- server_base_uri = "https://api.bitbucket.org/2.0/repositories/Ty/more/downloads"
- def main():
- c = ClientSecrets()
- # Fetch a request token
- bitbucket = OAuth2Session(c.client_id)
- # Redirect user to Bitbucket for authorization
- authorization_url = bitbucket.authorization_url(c.auth_uri)
- print('Please go here and authorize: {}'.format(authorization_url[0]))
- # Get the authorization verifier code from the callback url
- redirect_response = input('https://api.bitbucket.org/2.0/repositories/Tysondogerz/more/downloads: https://api.bitbucket.org/2.0/repositories/Tysondogerz/more/downloads')
- redirect_response = raw_input('Paste the full redirect URL here:') ########Stops here #########################
- # Fetch the access token
- bitbucket.fetch_token(
- c.token_uri,
- authorization_response=redirect_response,
- username=c.client_id,
- password=c.client_secret)
- # Fetch a protected resource, i.e. user profile
- r = bitbucket.get(c.server_base_uri + '1.0/user')
- print(r.content)
- print('hi')
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement