INNER CODE UNIT · Python
authorized
LiuChangFreeman/OneIndexServerless · Deploy/Back/main.py:91
def authorized():
global token
try:
code=request.args.get("code")
final = request.args.get("final")
url = "https://login.microsoftonline.com/common/oauth2/v2.0/token"
headers = {
"Content-Type": "application/x-www-form-urlencoded"
}
form = "client_id={}&redirect_uri={}&client_secret={}&code={}&grant_type=authorization_code".format(client_id,redirect_uri_register,client_secret,code)
token = requests.post(url, headers=headers, data=form).json()
token["time"] = time.time()
path = "me/drive"
url = base_url + path
access_token = token["access_token"]
headers = {
"Authorization": "bearer {}".format(access_token),
"Content-Type": "application/json"