如何解决带有API的python中的AdalError
我正在尝试使用Power Bi API,如下所示 并得到此错误:
import { Auth } from 'aws-amplify';
try {
const cognitoUser = await Auth.currentAuthenticatedUser();
const currentSession = await Auth.currentSession();
cognitoUser.refreshSession(currentSession.refreshToken,(err,session) => {
console.log('session',err,session);
const { idToken,refreshToken,accessToken } = session;
// do whatever you want to do now :)
});
} catch (e) {
console.log('Unable to refresh Token',e);
}
输出:
import adal
import requests
import json
import pandas
import requests
print(requests.get("https://login.windows.net/common/UserRealm/johndoe@contoso.com?api-version=1.0").text)
输入:
{"ver":"1.0","account_type":"Managed","domain_name":"contoso.com","cloud_instance_name":"microsoftonline.com","cloud_audience_urn":"urn:federation:MicrosoftOnline"}
错误:
authority_url = 'https://login.windows.net/common'
resource_url = 'https://analysis.windows.net/powerbi/api'
client_id = 'myclient_id '
username = 'myusername'
password = 'mypassword'
context = adal.AuthenticationContext(authority=authority_url,validate_authority=True,api_version=None)
token = context.acquire_token_with_username_password(resource=resource_url,client_id=client_id,username=username,password=password)
注意:出于隐私原因,我对错误消息(URL)进行了一些修改
任何想法是什么意思?
解决方法
问题来自设置
authority_url = 'https://login.windows.net/common'
resource_url = 'https://analysis.windows.net/powerbi/api'
client_id = 'myclient_id '
username = 'myusername'
password = 'mypassword'
我不知道哪一位,可能是client_id
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。