コード例 #1
0
 async def get_request_auth_headers(self):
     url, data, headers = auth.create_access_token_request_params(self)
     async with aiohttp.ClientSession() as session:
         async with session.post(url, data=data,
                                 headers=headers) as response:
             response_json = await response.json()
             self.access_token = response_json["access_token"]
             self.headers.update(
                 dict(Authorization="Bearer {}".format(self.access_token),
                      apikey=self.api_key))
コード例 #2
0
    def get_request_auth_headers(self):
        url, data, headers = auth.create_access_token_request_params(self)
        response = requests.post(url=url, headers=headers, data=data)

        self.access_token = None
        if response and response.status_code == requests.codes["ok"]:
            response_json = response.json()
            self.access_token = response_json["access_token"]

        self.headers.update(
            dict(Authorization="Bearer {}".format(self.access_token),
                 apikey=self.api_key))
        return self.headers
コード例 #3
0
    def get_request_auth_headers(self):
        url, data, headers = auth.create_access_token_request_params(self)
        response = requests.post(url=url, headers=headers, data=data)

        self.access_token = None
        if response and response.status_code == requests.codes["ok"]:
            response_json = response.json()
            self.access_token = response_json["access_token"]

        self.headers.update({
            "Authorization":
            "Bearer {}".format(self.access_token),
            "apikey":
            self.api_key,
            "User-Agent":
            self.user_agent,
        })
        return self.headers