嗨,我是从API获取数据的新手:
我试图从Qt应用程序发送电子邮件,从文本编辑器获取电子邮件和密码我的问题是当我试图从microsoft(Azure)获取api身份验证时
from urllib.parse import quote, urlencode
import base64
import json
import time
# Client ID and secret
client_id = 'UUUUUUUUUUUUUUUUUUUUUUUU'
client_secret = ' PPPPPPPPPPPPPPPPP'
# Constant strings for OAuth2 flow
# The OAuth authority
authority = 'https://login.microsoftonline.com'
# The authorize URL that initiates the OAuth2 client credential flow for admin consent
authorize_url = '{0}{1}'.format(authority, '/common/oauth2/v2.0/authorize?{0}')
# The token issuing endpoint
token_url = '{0}{1}'.format(authority, '/common/oauth2/v2.0/token')
# The scopes required by the app
scopes = [ 'Mail.Read',
'Mail.Send' ]
def get_signin_url(redirect_uri):
# Build the query parameters for the signin url
params = { 'client_id': client_id,
'redirect_uri': redirect_uri,
'response_type': 'code',
'scope': ' '.join(str(i) for i in scopes)
}
signin_url = authorize_url.format(urlencode(params))
return signin_url
此代码用于生成要登录的url,该url由以下调用:
def Message_Send():
Sign = QS.get_signin_url('Directorio://auth')
data={
'loginfmt':'XXXXXXXXX',
'passwd':'YYYYYYYYY'
}
requ = requests.Session()
geto=requ.post(Sign,)
但是当我试图从geto获取json时,如果我使用获取文本给我看一个没有正文的HTML页面
json.decoder.JSONDecodeError: Expecting value: line 3 column 1 (char 4)
这是使用json时的错误 我的状态码是200 应用程序UI由pyqt制作
目前没有回答
相关问题 更多 >
编程相关推荐