Skip to content

Commit

Permalink
Update the commandline-oauth-scopes.py example (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-db authored May 25, 2023
1 parent 223fe46 commit 487793d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions example/oauth/commandline-oauth-scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

try:
oauth_result = auth_flow.finish(auth_code)
# Oauth token has files.metadata.read scope only
# authorization has files.metadata.read scope only
assert oauth_result.scope == 'files.metadata.read'
except Exception as e:
print('Error: %s' % (e,))
Expand All @@ -33,7 +33,7 @@
auth_flow2 = DropboxOAuth2FlowNoRedirect(APP_KEY,
consumer_secret=APP_SECRET,
token_access_type='offline',
scope=['files.metadata.write'])
scope=['account_info.read'])

authorize_url = auth_flow2.start()
print("1. Go to: " + authorize_url)
Expand All @@ -43,8 +43,8 @@

try:
oauth_result = auth_flow2.finish(auth_code)
# Oauth token has files.metadata.write scope only
assert oauth_result.scope == 'files.metadata.write'
# authorization has account_info.read scope only
assert oauth_result.scope == 'account_info.read'
except Exception as e:
print('Error: %s' % (e,))
exit(1)
Expand All @@ -66,8 +66,8 @@
try:
oauth_result = auth_flow3.finish(auth_code)
print(oauth_result)
# Oauth token has all granted user scopes
assert 'files.metadata.write' in oauth_result.scope
# authorization has all granted user scopes
assert 'account_info.read' in oauth_result.scope
assert 'files.metadata.read' in oauth_result.scope
assert 'files.content.read' in oauth_result.scope
assert 'files.content.write' in oauth_result.scope
Expand All @@ -80,5 +80,6 @@
oauth2_access_token_expiration=oauth_result.expires_at,
oauth2_refresh_token=oauth_result.refresh_token,
app_key=APP_KEY,
app_secret=APP_SECRET):
app_secret=APP_SECRET) as dbx:
dbx.users_get_current_account()
print("Successfully set up client!")

0 comments on commit 487793d

Please sign in to comment.