Database Reference
In-Depth Information
OAuth authorization process.
'''
# for the saved credentials. If the user has never
completed
# OAuth authorization this module will initiate the
process.
import httplib2
import json
import os
from apiclient import discovery
from oauth2client.client import flow_from_clientsecrets
from oauth2client.client import
SignedJwtAssertionCredentials
from oauth2client.file import Storage
from oauth2client.tools import run
BIGQUERY_SCOPE = 'https://www.googleapis.com/auth/
bigquery'
# Service account and keyfile only used for service
account auth.
SERVICE_ACCT = ('<service account
id>@developer.gserviceaccount.com')
# Set this to the full path to your service account
private key file.
KEY_FILE = 'key.p12'
def get_creds():
'''Get credentials for use in API requests.
Generates service account credentials if the key
file is present,
and regular user credentials if the file is not
found.
'''
if os.path.exists(KEY_FILE):
return get_service_acct_creds(SERVICE_ACCT,
KEY_FILE)
else:
return get_oauth2_creds()
def get_oauth2_creds():
Search WWH ::




Custom Search