当前位置: 首页>>代码示例>>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;未经允许,请勿转载。