def retrieve_token(self):
        """ retrieve access token with code fetched via 
        retrieve_authorization_code method.
        """

        if self.authorization_code:
            request_param = {
                "client_id": self.client_id,
                "client_secret": self.client_secret,
                "redirect_uri": self.redirect_uri,
                "code": self.authorization_code
                }

            if self._extra_token_params:
                request_param.update(self._extra_token_params)

            content_length = len(urlencode(request_param))
            headers = {
                'Content-Length': str(content_length),
                'Content-Type': 'application/x-www-form-urlencoded'
                }
        
            r = requests.post(self.token_uri, data=request_param,
                              headers=headers)
            jsondata = json.loads(r.text)
            self.access_token = jsondata
            return self.access_token

        else:
            print("authorization code is required before getting accesss token")
            print("Please call retrieve_authorization_code() beforehand")
def retrieve_token ( self ) : if self . authorization_code : request_param = { "client_id" : self . client_id , "client_secret" : self . client_secret , "redirect_uri" : self . redirect_uri , "code" : self . authorization_code } if self . _extra_token_params : request_param . update ( self . _extra_token_params ) content_length = len ( urlencode ( request_param ) ) headers = { 'Content-Length' : str ( content_length ) , 'Content-Type' : 'application/x-www-form-urlencoded' } r = requests . post ( self . token_uri , data = request_param , headers = headers ) jsondata = json . loads ( r . text ) self . access_token = jsondata return self . access_token else : print ( "authorization code is required before getting accesss token" ) print ( "Please call retrieve_authorization_code() beforehand" )
retrieve access token with code fetched via 
        retrieve_authorization_code method.