Created
September 4, 2013 03:51
-
-
Save imduffy15/6432586 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/env python | |
| import httplib2 | |
| from oauth2client.client import flow_from_clientsecrets | |
| from oauth2client.file import Storage | |
| from oauth2client.tools import run | |
| from apiclient.discovery import build | |
| CLIENT_SECRETS = 'client_secrets.json' | |
| OAUTH2_STORAGE = 'oauth2.dat' | |
| GCE_SCOPE = 'https://localhost:5000' | |
| API_VERSION = 'v1beta15' | |
| GCE_URL = 'https://localhost:5000' | |
| def main(): | |
| # Perform OAuth 2.0 authorization. | |
| flow = flow_from_clientsecrets(CLIENT_SECRETS, scope=GCE_SCOPE) | |
| storage = Storage(OAUTH2_STORAGE) | |
| credentials = storage.get() | |
| if credentials is None or credentials.invalid: | |
| credentials = run(flow, storage) | |
| http = httplib2.Http(disable_ssl_certificate_validation=True) | |
| auth_http = credentials.authorize(http) | |
| gce_service = build('compute', API_VERSION) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment