Exemplo n.º 1
0
 def authorization(self):
     if self._request.response_type != "code":
         raise InvalidRequestError()
     state = self._request.state
     if not state:
         state = generate_random_from_vschar_set(length=30)
     self._state = state
     #self._request.save_session(AUTHORIZATION_STATE_KEY , state)
     self._server.check_available_scope(self._client, self._request.scope)
     code = self._server.generate_code(self._client, self._request.scope, self._request.user)
     return add_params_to_url(self.redirect_uri, {'code': code, 'state': self._state})
Exemplo n.º 2
0
    def implicit(self, expires_in):
        if self._request.response_type != "token":
            raise InvalidRequestError()

        redirect_uri = self._request.redirect_uri
        state = self._request.state
        scope = self._request.scope
        if not state:
            state = generate_random_from_vschar_set(length=30)

        access_token = self._server.generate_access_token(self._client, self._request.user, scope, expires_in,
                                                          is_refreshable=False)
        return add_params_to_url(redirect_uri,
                                 {'access_token': access_token.access_token, 'state': state, 'scope': ' '.join(scope),
                                  'expires_in': expires_in, 'token_type': 'Bearer'})
Exemplo n.º 3
0
 def to_uri(self, redirect_uri):
     return add_params_to_url(redirect_uri, self.to_dict())