forked from googleapis/google-api-python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make compatible with oauth2client v2.0.0
The v2.0.0 release moved a few modules to a subpackage of oauth2client called contrib. Among these was the locked_file module necessary for credential storage. Sample code for Django, App Engine and Service Accounts needed updates as well.
- Loading branch information
1 parent
d83246e
commit 2122d3c
Showing
7 changed files
with
18 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,23 +34,19 @@ | |
import sys | ||
|
||
from googleapiclient.discovery import build | ||
from oauth2client.client import SignedJwtAssertionCredentials | ||
from oauth2client.service_account import ServiceAccountCredentials | ||
|
||
def main(argv): | ||
# Load the key in PKCS 12 format that you downloaded from the Google API | ||
# Console when you created your Service account. | ||
f = file('key.p12', 'rb') | ||
key = f.read() | ||
f.close() | ||
|
||
# Create an httplib2.Http object to handle our HTTP requests and authorize it | ||
# with the Credentials. Note that the first parameter, service_account_name, | ||
# is the Email address created for the Service account. It must be the email | ||
# address associated with the key that was created. | ||
credentials = SignedJwtAssertionCredentials( | ||
'[email protected]', | ||
key, | ||
scope='https://www.googleapis.com/auth/tasks') | ||
# Load the json format key that you downloaded from the Google API | ||
# Console when you created your service account. For p12 keys, use the | ||
# from_p12_keyfile method of ServiceAccountCredentials and specify the | ||
# service account email address, p12 keyfile, and scopes. | ||
credentials = ServiceAccountCredentials.from_json_keyfile_name( | ||
'service-account-abcdef123456.json', | ||
scopes='https://www.googleapis.com/auth/tasks') | ||
|
||
# Create an httplib2.Http object to handle our HTTP requests and authorize | ||
# it with the Credentials. | ||
http = httplib2.Http() | ||
http = credentials.authorize(http) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters