예제 #1
0
파일: oauth.py 프로젝트: hahnicity/slothpal
 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()
     )
예제 #2
0
파일: oauth.py 프로젝트: hahnicity/slothpal
 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()
예제 #3
0
파일: oauth.py 프로젝트: hahnicity/slothpal
 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())
예제 #4
0
파일: oauth.py 프로젝트: hahnicity/slothpal
 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()