def create_service(authenticated=True): http = httplib2.Http(ca_certs=utils.get_cacerts_path()) if authenticated: credentials = oauth.get_or_create_credentials( scope=OAUTH_SCOPE, storage_key='Grow SDK') http = credentials.authorize(http) key = None if authenticated else oauth.BROWSER_API_KEY return discovery.build('blogger', 'v3', http=http, developerKey=key)
def _get_parser(): global _parser if _parser is None: credentials = oauth.get_or_create_credentials( scope=SCOPES, storage_key=STORAGE_KEY) http = httplib2.Http(ca_certs=utils.get_cacerts_path()) http = credentials.authorize(http) service = discovery.build('language', 'v1beta2', http=http) _parser = budou.get_parser('nlapi', service=service) return _parser
def create_service(host): credentials = oauth.get_or_create_credentials( scope=OAUTH_SCOPES, storage_key=STORAGE_KEY) http = httplib2.Http(ca_certs=utils.get_cacerts_path()) http = credentials.authorize(http) # Kintaro's server doesn't seem to be able to refresh expired tokens # properly (responds with a "Stateless token expired" error). So for # now, automatically refresh tokens each time a service is created. If # this isn't fixed on the Kintaro end, what we can do is implement our # own refresh system (tokens need to be refreshed once per hour). credentials.refresh(http) url = DISCOVERY_URL.replace('{host}', host) return discovery.build('content', 'v1', http=http, discoveryServiceUrl=url)
def create_service(self, host): credentials = oauth.get_or_create_credentials(scope=OAUTH_SCOPES, storage_key=STORAGE_KEY) http = httplib2.Http(ca_certs=utils.get_cacerts_path()) http = credentials.authorize(http) # Kintaro's server doesn't seem to be able to refresh expired tokens # properly (responds with a "Stateless token expired" error). So we # manage state ourselves and refresh slightly more often than once # per hour. now = datetime.datetime.now() if self._last_run is None \ or now - self._last_run >= datetime.timedelta(minutes=50): credentials.refresh(http) self._last_run = now url = DISCOVERY_URL.replace('{host}', host) return discovery.build('content', 'v1', http=http, discoveryServiceUrl=url)
def patched_get_credentials(*args): """Gets credentials from Grow's flow.""" return oauth.get_or_create_credentials(scope=OAUTH_SCOPE, storage_key=STORAGE_KEY)
def create_service(api='drive', version='v2'): credentials = oauth.get_or_create_credentials( scope=OAUTH_SCOPE, storage_key='Grow SDK') http = httplib2.Http(ca_certs=utils.get_cacerts_path()) http = credentials.authorize(http) return discovery.build(api, version, http=http)
def http(self): credentials = oauth.get_or_create_credentials(scope=OAUTH_SCOPE, storage_key=STORAGE_KEY) http = httplib2.Http(ca_certs=utils.get_cacerts_path()) http = credentials.authorize(http) return http
def create_service(): credentials = oauth.get_or_create_credentials( scope=OAUTH_SCOPE, storage_key='Grow SDK') http = httplib2.Http(ca_certs=utils.get_cacerts_path()) http = credentials.authorize(http) return discovery.build('drive', 'v2', http=http)
def http(self): credentials = oauth.get_or_create_credentials( scope=OAUTH_SCOPE, storage_key=STORAGE_KEY) http = httplib2.Http(ca_certs=utils.get_cacerts_path()) http = credentials.authorize(http) return http