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


Python AccessTokenRequest.to_dict方法代码示例

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


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

示例1: test_token_endpoint_unauth

# 需要导入模块: from oic.oic.message import AccessTokenRequest [as 别名]
# 或者: from oic.oic.message.AccessTokenRequest import to_dict [as 别名]
    def test_token_endpoint_unauth(self):
        authreq = AuthorizationRequest(state="state",
                                       redirect_uri="http://example.com/authz",
                                       client_id="client_1")

        _sdb = self.server.sdb
        sid = _sdb.token.key(user="sub", areq=authreq)
        access_grant = _sdb.token(sid=sid)
        ae = AuthnEvent("user")
        _sdb[sid] = {
            "authn_event": ae,
            "oauth_state": "authz",
            "authzreq": "",
            "client_id": "client_1",
            "code": access_grant,
            "code_used": False,
            "scope": ["openid"],
            "redirect_uri": "http://example.com/authz"
        }
        _sdb.do_sub(sid)

        # Construct Access token request
        areq = AccessTokenRequest(code=access_grant,
                                  redirect_uri="http://example.com/authz",
                                  client_id="client_1", client_secret="secret", )

        print areq.to_dict()
        txt = areq.to_urlencoded()

        resp = self.server.token_endpoint(request=txt, remote_user="client2",
                                          request_method="POST")
        print resp
        atr = TokenErrorResponse().deserialize(resp.message, "json")
        print atr.keys()
        assert _eq(atr.keys(), ['error'])
开发者ID:dallerbarn,项目名称:pyoidc,代码行数:37,代码来源:test_oic_provider.py

示例2: test_token_endpoint_unauth

# 需要导入模块: from oic.oic.message import AccessTokenRequest [as 别名]
# 或者: from oic.oic.message.AccessTokenRequest import to_dict [as 别名]
def test_token_endpoint_unauth():
    server = provider_init

    authreq = AuthorizationRequest(state="state",
                                   redirect_uri="http://example.com/authz",
                                   client_id="client_1")

    _sdb = server.sdb
    sid = _sdb.token.key(user="user_id", areq=authreq)
    access_grant = _sdb.token(sid=sid)
    _sdb[sid] = {
        "oauth_state": "authz",
        "sub": "user_id",
        "authzreq": "",
        "client_id": "client_1",
        "code": access_grant,
        "code_used": False,
        "scope": ["openid"],
        "redirect_uri":"http://example.com/authz"
    }

    # Construct Access token request
    areq = AccessTokenRequest(code=access_grant,
                              redirect_uri="http://example.com/authz",
                              client_id="client_1", client_secret="secret",)

    print areq.to_dict()
    str = areq.to_urlencoded()
    fil = StringIO.StringIO(buf=str)
    environ = BASE_ENVIRON.copy()
    environ["CONTENT_LENGTH"] = len(str)
    environ["wsgi.input"] = fil
    environ["REMOTE_USER"] = "client2"
    environ["REQUEST_METHOD"] = "POST"

    resp = server.token_endpoint(environ, start_response)
    print resp
    atr = TokenErrorResponse().deserialize(resp[0] ,"json")
    print atr.keys()
    assert _eq(atr.keys(), ['error'])
开发者ID:asheidan,项目名称:pyoidc,代码行数:42,代码来源:test_oic_provider.py


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