Ejemplo n.º 1
0
    def test_it_returns_an_oauth_compliant_response(self, pyramid_request, oauth_service):
        token = models.Token()
        oauth_service.create_token.return_value = token

        assert views.access_token(pyramid_request) == {
            'access_token': token.value,
            'token_type': 'bearer',
            'expires_in': TOKEN_TTL.total_seconds(),
        }
Ejemplo n.º 2
0
def access_token(request):
    svc = request.find_service(name='oauth')

    user, authclient = svc.verify_jwt_bearer(
        assertion=request.POST.get('assertion'),
        grant_type=request.POST.get('grant_type'))
    token = svc.create_token(user, authclient)

    return {
        'access_token': token.value,
        'token_type': 'bearer',
        'expires_in': TOKEN_TTL.total_seconds(),
    }