当前位置: 首页>>代码示例>>Python>>正文


Python crypt.make_signed_jwt方法代码示例

本文整理汇总了Python中oauth2client.crypt.make_signed_jwt方法的典型用法代码示例。如果您正苦于以下问题:Python crypt.make_signed_jwt方法的具体用法?Python crypt.make_signed_jwt怎么用?Python crypt.make_signed_jwt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oauth2client.crypt的用法示例。


在下文中一共展示了crypt.make_signed_jwt方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _generate_assertion

# 需要导入模块: from oauth2client import crypt [as 别名]
# 或者: from oauth2client.crypt import make_signed_jwt [as 别名]
def _generate_assertion(self):
    """Generate the assertion that will be used in the request."""
    now = long(time.time())
    payload = {
        'aud': self.token_uri,
        'scope': self.scope,
        'iat': now,
        'exp': now + SignedJwtAssertionCredentials.MAX_TOKEN_LIFETIME_SECS,
        'iss': self.service_account_name
    }
    payload.update(self.kwargs)
    logger.debug(str(payload))

    private_key = base64.b64decode(self.private_key)
    return crypt.make_signed_jwt(crypt.Signer.from_string(
        private_key, self.private_key_password), payload)

# Only used in verify_id_token(), which is always calling to the same URI
# for the certs. 
开发者ID:mortcanty,项目名称:earthengine,代码行数:21,代码来源:client.py

示例2: _generate_assertion

# 需要导入模块: from oauth2client import crypt [as 别名]
# 或者: from oauth2client.crypt import make_signed_jwt [as 别名]
def _generate_assertion(self):
      """Generate the assertion that will be used in the request."""
      now = long(time.time())
      payload = {
          'aud': self.token_uri,
          'scope': self.scope,
          'iat': now,
          'exp': now + SignedJwtAssertionCredentials.MAX_TOKEN_LIFETIME_SECS,
          'iss': self.service_account_name
      }
      payload.update(self.kwargs)
      logger.debug(str(payload))

      private_key = base64.b64decode(self.private_key)
      return crypt.make_signed_jwt(crypt.Signer.from_string(
          private_key, self.private_key_password), payload)

  # Only used in verify_id_token(), which is always calling to the same URI
  # for the certs. 
开发者ID:splunk,项目名称:splunk-ref-pas-code,代码行数:21,代码来源:client.py

示例3: _GenerateAssertion

# 需要导入模块: from oauth2client import crypt [as 别名]
# 或者: from oauth2client.crypt import make_signed_jwt [as 别名]
def _GenerateAssertion(self):
    """Generates the signed assertion that will be used in the request.

    Returns:
      string, signed Json Web Token (JWT) assertion.
    """
    now = int(time.time())
    payload = {
        'aud': RpcHelper.TOKEN_ENDPOINT,
        'scope': 'https://www.googleapis.com/auth/identitytoolkit',
        'iat': now,
        'exp': now + RpcHelper.MAX_TOKEN_LIFETIME_SECS,
        'iss': self.service_account_email
    }
    return crypt.make_signed_jwt(
        crypt.Signer.from_string(self.service_account_key),
        payload) 
开发者ID:google,项目名称:identity-toolkit-python-client,代码行数:19,代码来源:rpchelper.py

示例4: _create_token

# 需要导入模块: from oauth2client import crypt [as 别名]
# 或者: from oauth2client.crypt import make_signed_jwt [as 别名]
def _create_token(self, additional_claims=None):
        now = client._UTCNOW()
        lifetime = datetime.timedelta(seconds=self._MAX_TOKEN_LIFETIME_SECS)
        expiry = now + lifetime
        payload = {
            'iat': _datetime_to_secs(now),
            'exp': _datetime_to_secs(expiry),
            'iss': self._service_account_email,
            'sub': self._service_account_email
        }
        payload.update(self._kwargs)
        if additional_claims is not None:
            payload.update(additional_claims)
        jwt = crypt.make_signed_jwt(self._signer, payload,
                                    key_id=self._private_key_id)
        return jwt.decode('ascii'), expiry 
开发者ID:fniephaus,项目名称:alfred-gmail,代码行数:18,代码来源:service_account.py

示例5: _generate_assertion

# 需要导入模块: from oauth2client import crypt [as 别名]
# 或者: from oauth2client.crypt import make_signed_jwt [as 别名]
def _generate_assertion(self):
        """Generate the assertion that will be used in the request."""
        now = int(time.time())
        payload = {
            'aud': self.token_uri,
            'scope': self.scope,
            'iat': now,
            'exp': now + SignedJwtAssertionCredentials.MAX_TOKEN_LIFETIME_SECS,
            'iss': self.service_account_name
        }
        payload.update(self.kwargs)
        logger.debug(str(payload))

        private_key = base64.b64decode(self.private_key)
        return crypt.make_signed_jwt(crypt.Signer.from_string(
            private_key, self.private_key_password), payload)

# Only used in verify_id_token(), which is always calling to the same URI
# for the certs. 
开发者ID:jmankoff,项目名称:data,代码行数:21,代码来源:client.py

示例6: _generate_assertion

# 需要导入模块: from oauth2client import crypt [as 别名]
# 或者: from oauth2client.crypt import make_signed_jwt [as 别名]
def _generate_assertion(self):
        """Generate the assertion that will be used in the request."""
        now = int(time.time())
        payload = {
            'aud': self.token_uri,
            'scope': self._scopes,
            'iat': now,
            'exp': now + self.MAX_TOKEN_LIFETIME_SECS,
            'iss': self._service_account_email,
        }
        payload.update(self._kwargs)
        return crypt.make_signed_jwt(self._signer, payload,
                                     key_id=self._private_key_id) 
开发者ID:Deltares,项目名称:aqua-monitor,代码行数:15,代码来源:service_account.py

示例7: _create_token

# 需要导入模块: from oauth2client import crypt [as 别名]
# 或者: from oauth2client.crypt import make_signed_jwt [as 别名]
def _create_token(self, additional_claims=None):
        now = _UTCNOW()
        expiry = now + datetime.timedelta(seconds=self._MAX_TOKEN_LIFETIME_SECS)
        payload = {
            'iat': _datetime_to_secs(now),
            'exp': _datetime_to_secs(expiry),
            'iss': self._service_account_email,
            'sub': self._service_account_email
        }
        payload.update(self._kwargs)
        if additional_claims is not None:
            payload.update(additional_claims)
        jwt = crypt.make_signed_jwt(self._signer, payload,
                                    key_id=self._private_key_id)
        return jwt.decode('ascii'), expiry 
开发者ID:Deltares,项目名称:aqua-monitor,代码行数:17,代码来源:service_account.py

示例8: _create_signed_jwt

# 需要导入模块: from oauth2client import crypt [as 别名]
# 或者: from oauth2client.crypt import make_signed_jwt [as 别名]
def _create_signed_jwt(self):
        private_key = datafile('privatekey.' + self.format_)
        signer = self.signer.from_string(private_key)
        audience = 'some_audience_address@testing.gserviceaccount.com'
        now = int(time.time())

        return crypt.make_signed_jwt(signer, {
            'aud': audience,
            'iat': now,
            'exp': now + 300,
            'user': 'billy bob',
            'metadata': {'meta': 'data'},
        }) 
开发者ID:haynieresearch,项目名称:jarvis,代码行数:15,代码来源:test_jwt.py

示例9: test_verify_id_token_bad_tokens

# 需要导入模块: from oauth2client import crypt [as 别名]
# 或者: from oauth2client.crypt import make_signed_jwt [as 别名]
def test_verify_id_token_bad_tokens(self):
        private_key = datafile('privatekey.' + self.format_)

        # Wrong number of segments
        self._check_jwt_failure('foo', 'Wrong number of segments')

        # Not json
        self._check_jwt_failure('foo.bar.baz', 'Can\'t parse token')

        # Bad signature
        jwt = b'.'.join([b'foo',
                         _helpers._urlsafe_b64encode('{"a":"b"}'),
                         b'baz'])
        self._check_jwt_failure(jwt, 'Invalid token signature')

        # No expiration
        signer = self.signer.from_string(private_key)
        audience = ('https:#www.googleapis.com/auth/id?client_id='
                    'external_public_key@testing.gserviceaccount.com')
        jwt = crypt.make_signed_jwt(signer, {
            'aud': audience,
            'iat': time.time(),
        })
        self._check_jwt_failure(jwt, 'No exp field in token')

        # No issued at
        jwt = crypt.make_signed_jwt(signer, {
            'aud': 'audience',
            'exp': time.time() + 400,
        })
        self._check_jwt_failure(jwt, 'No iat field in token')

        # Too early
        jwt = crypt.make_signed_jwt(signer, {
            'aud': 'audience',
            'iat': time.time() + 301,
            'exp': time.time() + 400,
        })
        self._check_jwt_failure(jwt, 'Token used too early')

        # Too late
        jwt = crypt.make_signed_jwt(signer, {
            'aud': 'audience',
            'iat': time.time() - 500,
            'exp': time.time() - 301,
        })
        self._check_jwt_failure(jwt, 'Token used too late')

        # Wrong target
        jwt = crypt.make_signed_jwt(signer, {
            'aud': 'somebody else',
            'iat': time.time(),
            'exp': time.time() + 300,
        })
        self._check_jwt_failure(jwt, 'Wrong recipient') 
开发者ID:haynieresearch,项目名称:jarvis,代码行数:57,代码来源:test_jwt.py


注:本文中的oauth2client.crypt.make_signed_jwt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。