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(), }
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(), }