Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the commandline-oauth-scopes.py example #470

Merged
merged 1 commit into from
May 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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!")