當前位置: 首頁>>代碼示例>>Python>>正文


Python client.AccessTokenRefreshError方法代碼示例

本文整理匯總了Python中oauth2client.client.AccessTokenRefreshError方法的典型用法代碼示例。如果您正苦於以下問題:Python client.AccessTokenRefreshError方法的具體用法?Python client.AccessTokenRefreshError怎麽用?Python client.AccessTokenRefreshError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在oauth2client.client的用法示例。


在下文中一共展示了client.AccessTokenRefreshError方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _refresh

# 需要導入模塊: from oauth2client import client [as 別名]
# 或者: from oauth2client.client import AccessTokenRefreshError [as 別名]
def _refresh(self, http_request):
    """Refreshes the access_token.

    Since the underlying App Engine app_identity implementation does its own
    caching we can skip all the storage hoops and just to a refresh using the
    API.

    Args:
      http_request: callable, a callable that matches the method signature of
        httplib2.Http.request, used to make the refresh request.

    Raises:
      AccessTokenRefreshError: When the refresh fails.
    """
    try:
      scopes = self.scope.split()
      (token, _) = app_identity.get_access_token(
          scopes, service_account_id=self.service_account_id)
    except app_identity.Error as e:
      raise AccessTokenRefreshError(str(e))
    self.access_token = token 
開發者ID:mortcanty,項目名稱:earthengine,代碼行數:23,代碼來源:appengine.py

示例2: _refresh

# 需要導入模塊: from oauth2client import client [as 別名]
# 或者: from oauth2client.client import AccessTokenRefreshError [as 別名]
def _refresh(self, http_request):
    """Refreshes the access_token.

    Since the underlying App Engine app_identity implementation does its own
    caching we can skip all the storage hoops and just to a refresh using the
    API.

    Args:
      http_request: callable, a callable that matches the method signature of
        httplib2.Http.request, used to make the refresh request.

    Raises:
      AccessTokenRefreshError: When the refresh fails.
    """
    try:
      scopes = self.scope.split()
      (token, _) = app_identity.get_access_token(scopes)
    except app_identity.Error, e:
      raise AccessTokenRefreshError(str(e)) 
開發者ID:splunk,項目名稱:splunk-ref-pas-code,代碼行數:21,代碼來源:appengine.py

示例3: _refresh

# 需要導入模塊: from oauth2client import client [as 別名]
# 或者: from oauth2client.client import AccessTokenRefreshError [as 別名]
def _refresh(self, http_request):
    """Refreshes the access_token.

    Skip all the storage hoops and just refresh using the API.

    Args:
      http_request: callable, a callable that matches the method signature of
        httplib2.Http.request, used to make the refresh request.

    Raises:
      AccessTokenRefreshError: When the refresh fails.
    """
    uri = uritemplate.expand(META, {'scope': self.scope})
    response, content = http_request(uri)
    if response.status == 200:
      try:
        d = simplejson.loads(content)
      except StandardError, e:
        raise AccessTokenRefreshError(str(e))
      self.access_token = d['accessToken'] 
開發者ID:splunk,項目名稱:splunk-ref-pas-code,代碼行數:22,代碼來源:gce.py

示例4: test_refresh_failure

# 需要導入模塊: from oauth2client import client [as 別名]
# 或者: from oauth2client.client import AccessTokenRefreshError [as 別名]
def test_refresh_failure(self):
        """
        Failure to refresh the access token should be treated as auth error.
        """

        def raise_invalid_grant(*args, **kwargs):
            raise AccessTokenRefreshError()

        with mock.patch('sndlatr.models.get_credentials') as getter, \
            self.notify_mock() as notify:
            cred = mock.MagicMock(spec=OAuth2Credentials)
            getter.return_value = cred
            cred.refresh.side_effect = raise_invalid_grant

            job = self.create_job(error_cnt=self.JOB_MAX_RETRIES)
            resp = self._post_send(job)
            self.assertEquals(resp.status_int, 200)
            notify.assert_called_with(job, 'auth') 
開發者ID:Schibum,項目名稱:sndlatr,代碼行數:20,代碼來源:api_tests.py

示例5: _refresh

# 需要導入模塊: from oauth2client import client [as 別名]
# 或者: from oauth2client.client import AccessTokenRefreshError [as 別名]
def _refresh(self, http_request):
        """Refreshes the access_token.

        Since the underlying App Engine app_identity implementation does its
        own caching we can skip all the storage hoops and just to a refresh
        using the API.

        Args:
            http_request: callable, a callable that matches the method
                          signature of httplib2.Http.request, used to make the
                          refresh request.

        Raises:
            AccessTokenRefreshError: When the refresh fails.
        """
        try:
            scopes = self.scope.split()
            (token, _) = app_identity.get_access_token(
                scopes, service_account_id=self.service_account_id)
        except app_identity.Error as e:
            raise AccessTokenRefreshError(str(e))
        self.access_token = token 
開發者ID:Deltares,項目名稱:aqua-monitor,代碼行數:24,代碼來源:appengine.py

示例6: _refresh

# 需要導入模塊: from oauth2client import client [as 別名]
# 或者: from oauth2client.client import AccessTokenRefreshError [as 別名]
def _refresh(self, http_request):
        """Refreshes the access_token.

        Since the underlying App Engine app_identity implementation does its
        own caching we can skip all the storage hoops and just to a refresh
        using the API.

        Args:
            http_request: callable, a callable that matches the method
                          signature of httplib2.Http.request, used to make the
                          refresh request.

        Raises:
            AccessTokenRefreshError: When the refresh fails.
        """
        try:
            scopes = self.scope.split()
            (token, _) = app_identity.get_access_token(
                scopes, service_account_id=self.service_account_id)
        except app_identity.Error as e:
            raise client.AccessTokenRefreshError(str(e))
        self.access_token = token 
開發者ID:fniephaus,項目名稱:alfred-gmail,代碼行數:24,代碼來源:appengine.py

示例7: _refresh

# 需要導入模塊: from oauth2client import client [as 別名]
# 或者: from oauth2client.client import AccessTokenRefreshError [as 別名]
def _refresh(self, http):
        """Refreshes the access token.

        Since the underlying App Engine app_identity implementation does its
        own caching we can skip all the storage hoops and just to a refresh
        using the API.

        Args:
            http: unused HTTP object

        Raises:
            AccessTokenRefreshError: When the refresh fails.
        """
        try:
            scopes = self.scope.split()
            (token, _) = app_identity.get_access_token(
                scopes, service_account_id=self.service_account_id)
        except app_identity.Error as e:
            raise client.AccessTokenRefreshError(str(e))
        self.access_token = token 
開發者ID:haynieresearch,項目名稱:jarvis,代碼行數:22,代碼來源:appengine.py

示例8: _refresh

# 需要導入模塊: from oauth2client import client [as 別名]
# 或者: from oauth2client.client import AccessTokenRefreshError [as 別名]
def _refresh(self, http_request):
    """Refreshes the access_token.

    Skip all the storage hoops and just refresh using the API.

    Args:
      http_request: callable, a callable that matches the method signature of
        httplib2.Http.request, used to make the refresh request.

    Raises:
      AccessTokenRefreshError: When the refresh fails.
    """
    query = '?scope=%s' % urllib.quote(self.scope, '')
    uri = META.replace('{?scope}', query)
    response, content = http_request(uri)
    if response.status == 200:
      try:
        d = json.loads(content)
      except StandardError as e:
        raise AccessTokenRefreshError(str(e))
      self.access_token = d['accessToken']
    else:
      if response.status == 404:
        content += (' This can occur if a VM was created'
                    ' with no service account or scopes.')
      raise AccessTokenRefreshError(content) 
開發者ID:mortcanty,項目名稱:earthengine,代碼行數:28,代碼來源:gce.py

示例9: get_credentials

# 需要導入模塊: from oauth2client import client [as 別名]
# 或者: from oauth2client.client import AccessTokenRefreshError [as 別名]
def get_credentials(self, job):
        credentials = models.get_credentials(job.user_id)
        if not credentials:
            logging.error(
                'no credentials stored for user {}'.format(job.user_id))
            raise HTTPSuccess()
        logging.debug('refreshing oauth token')
        try:
            credentials.refresh(httplib2.Http())
        except AccessTokenRefreshError, e:
            logging.warning('refreshing token failed: ' + str(e))
            raise gmail.AuthenticationError() 
開發者ID:Schibum,項目名稱:sndlatr,代碼行數:14,代碼來源:api.py


注:本文中的oauth2client.client.AccessTokenRefreshError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。