forked from westonplatter/fast_arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
related westonplatter#11. swap bearer for client in resources
- Loading branch information
1 parent
f832538
commit f2f583f
Showing
18 changed files
with
123 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
import requests | ||
|
||
|
||
def gen_headers(bearer): | ||
headers = { | ||
"Accept": "*/*", | ||
"Accept-Encoding": "gzip, deflate", | ||
"Accept-Language": "en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5", | ||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" | ||
} | ||
if bearer: | ||
headers["Authorization"] = "Bearer {0}".format(bearer) | ||
return headers | ||
|
||
|
||
def get(url=None, client=None, params={}): | ||
""" | ||
Execute HTTP GET | ||
""" | ||
bearer = (client.access_token if client else None) | ||
headers = gen_headers(bearer) | ||
res = requests.get(url, headers=headers, params=params, timeout=15) | ||
return res.json() | ||
|
||
|
||
def post(url=None, client=None, payload=None): | ||
""" | ||
Execute HTTP POST | ||
""" | ||
bearer = (client.access_token if client else None) | ||
headers = gen_headers(bearer) | ||
res = requests.post(url, headers=headers, data=payload, timeout=15) | ||
return res.json() | ||
# def gen_headers(bearer): | ||
# headers = { | ||
# "Accept": "*/*", | ||
# "Accept-Encoding": "gzip, deflate", | ||
# "Accept-Language": "en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5", | ||
# "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" | ||
# } | ||
# if bearer: | ||
# headers["Authorization"] = "Bearer {0}".format(bearer) | ||
# return headers | ||
# | ||
# | ||
# def get(url=None, client=None, params={}): | ||
# """ | ||
# Execute HTTP GET | ||
# """ | ||
# bearer = (client.access_token if client else None) | ||
# headers = gen_headers(bearer) | ||
# res = requests.get(url, headers=headers, params=params, timeout=15) | ||
# return res.json() | ||
# | ||
# | ||
# def post(url=None, client=None, payload=None): | ||
# """ | ||
# Execute HTTP POST | ||
# """ | ||
# bearer = (client.access_token if client else None) | ||
# headers = gen_headers(bearer) | ||
# res = requests.post(url, headers=headers, data=payload, timeout=15) | ||
# return res.json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.