(self)
return response
Returns a JSON formatted authorization code.
Returns a JSON formatted authorization code.
Returns a JSON formatted authorization code .
def grant_response(self):
        """Returns a JSON formatted authorization code."""
        if not self.valid:
            raise UnvalidatedRequest("This request is invalid or has not been"
                " validated.")
        if self.grant_type == "authorization_code":
            access_token = self._get_authorization_code_token()
        elif self.grant_type == "refresh_token":
            access_token = self._get_refresh_token()
        elif self.grant_type == "password":
            access_token = self._get_password_token()
        elif self.grant_type == "client_credentials":
            access_token = self._get_client_credentials_token()
        data = {
            'access_token': access_token.token,
            'expires_in': ACCESS_TOKEN_EXPIRATION}
        if self.authentication_method == MAC:
            data["token_type"] = "mac"
            data["mac_key"] = access_token.mac_key
            data["mac_algorithm"] = "hmac-sha-256"
        elif self.authentication_method == BEARER:
            data["token_type"] = "bearer"
        if access_token.refreshable:
            data['refresh_token'] = access_token.refresh_token
        if self.scope is not None:
            data['scope'] = ' '.join(self.scope)
        json_data = json.dumps(data)
        if self.callback is not None:
            json_data = "%s(%s);" % (self.callback, json_data)
        response = HttpResponse(
            content=json_data,
            content_type='application/json')
        response['Cache-Control'] = 'no-store'
        return response
def grant_response ( self ) : if not self . valid : raise UnvalidatedRequest ( "This request is invalid or has not been" " validated." ) if self . grant_type == "authorization_code" : access_token = self . _get_authorization_code_token ( ) elif self . grant_type == "refresh_token" : access_token = self . _get_refresh_token ( ) elif self . grant_type == "password" : access_token = self . _get_password_token ( ) elif self . grant_type == "client_credentials" : access_token = self . _get_client_credentials_token ( ) data = { 'access_token' : access_token . token , 'expires_in' : ACCESS_TOKEN_EXPIRATION } if self . authentication_method == MAC : data [ "token_type" ] = "mac" data [ "mac_key" ] = access_token . mac_key data [ "mac_algorithm" ] = "hmac-sha-256" elif self . authentication_method == BEARER : data [ "token_type" ] = "bearer" if access_token . refreshable : data [ 'refresh_token' ] = access_token . refresh_token if self . scope is not None : data [ 'scope' ] = ' ' . join ( self . scope ) json_data = json . dumps ( data ) if self . callback is not None : json_data = "%s(%s);" % ( self . callback , json_data ) response = HttpResponse ( content = json_data , content_type = 'application/json' ) response [ 'Cache-Control' ] = 'no-store' return response