import requests url = 'https://api.dropboxapi.com/oauth2/token' app_key = "m79mo7gg7mh8pez" app_secret = "by93yed7as4qlmo" access_code = "TEX7wlfjGgUAAAAAAAAANYydTr5XVeay4hFJyk_B2UA" data = { 'code': access_code, 'grant_type': 'authorization_code' } headers = { 'Content-Type': 'application/x-www-form-urlencoded' } response = requests.post(url, auth=(app_key, app_secret), data=data, headers=headers)