Esempio n. 1
0
 def _perform_tokenservice_post(self, grant_type, **kwargs):
     """
     Make a post to the PayPal
     """
     return post(
         "".join([self.endpoint, constants.TOKENSERVICE_ENDPOINT]),
         data="&".join([
             "grant_type={}".format(constants.AUTH_CODE),
             "client_id={}".format(self.id),
             "client_secret={}".format(self.__secret)] +
             ["{}={}".format(key, value) for key, value in kwargs.iteritems()]),
         headers=get_oauth_headers()
     )
Esempio n. 2
0
 def request_token(self):
     """
     Get an token from PayPal for our application
     """
     response = post("".join([self.endpoint, constants.OAUTH2_ENDPOINT]),
                     headers=get_oauth_headers(),
                     data="grant_type={}".format(constants.CLIENT_CRED),
                     auth=(self.id, self.__secret))
     self.time_of_response = time()
     if response.status_code != 200:
         raise StatusCodeError(response)
     else:
         # XXX This cannot be stored
         self.__token_response = response.json()
Esempio n. 3
0
 def _perform_tokenservice_post(self, grant_type, **kwargs):
     """
     Make a post to the PayPal
     """
     return post(
         "".join([self.endpoint, constants.TOKENSERVICE_ENDPOINT]),
         data="&".join([
             "grant_type={}".format(constants.AUTH_CODE), "client_id={}".
             format(self.id), "client_secret={}".format(self.__secret)
         ] + [
             "{}={}".format(key, value)
             for key, value in kwargs.iteritems()
         ]),
         headers=get_oauth_headers())
Esempio n. 4
0
 def request_token(self):
     """
     Get an token from PayPal for our application
     """
     response = post(
         "".join([self.endpoint, constants.OAUTH2_ENDPOINT]),
         headers=get_oauth_headers(),
         data="grant_type={}".format(constants.CLIENT_CRED),
         auth=(self.id, self.__secret)
     )
     self.time_of_response = time()
     if response.status_code != 200:
         raise StatusCodeError(response)
     else:
         # XXX This cannot be stored
         self.__token_response = response.json()