diff options
author | Edwin Amsler <EdwinGuy@GMail.com> | 2015-02-15 22:21:39 -0600 |
---|---|---|
committer | Edwin Amsler <EdwinGuy@GMail.com> | 2015-02-15 22:21:39 -0600 |
commit | 7be606951b22d77a53274d014cd94aae30af93f5 (patch) | |
tree | 02de881ef62ab98c8893f8910589f1aa3b731c77 /samples | |
parent | b29c1bcc9902aff0c9eda2e083898f993cb0b110 (diff) | |
download | oauth2client-7be606951b22d77a53274d014cd94aae30af93f5.tar.gz |
Fix example to be Python3 compatible, use format()
Both print() and format() are compatible from 2.6. Also, format() is much nicer to use for internationalization since you can define the location of your substitutions. It works similarly to Java and .net's format() as well. Great stuff!
Should I tackle the other examples as well, or is piece meal all right?
Diffstat (limited to 'samples')
-rw-r--r-- | samples/oauth2_for_devices.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/samples/oauth2_for_devices.py b/samples/oauth2_for_devices.py index b419ea4..6b3b72e 100644 --- a/samples/oauth2_for_devices.py +++ b/samples/oauth2_for_devices.py @@ -16,16 +16,16 @@ flow = OAuth2WebServerFlow(CLIENT_ID, CLIENT_SECRET, " ".join(SCOPES)) # Step 1: get user code and verification URL # https://developers.google.com/accounts/docs/OAuth2ForDevices#obtainingacode flow_info = flow.step1_get_device_and_user_codes() -print "Enter the following code at %s: %s" % (flow_info.verification_url, - flow_info.user_code) -print "Then press Enter." +print("Enter the following code at {0}: {1}".format(flow_info.verification_url, + flow_info.user_code)) +print("Then press Enter.") input() # Step 2: get credentials # https://developers.google.com/accounts/docs/OAuth2ForDevices#obtainingatoken credentials = flow.step2_exchange(device_flow_info=flow_info) -print "Access token:", credentials.access_token -print "Refresh token:", credentials.refresh_token +print("Access token: {0}".format(credentials.access_token)) +print("Refresh token: {0}".format(credentials.refresh_token)) # Get YouTube service # https://developers.google.com/accounts/docs/OAuth2ForDevices#callinganapi |