简体   繁体   English

Power BI Rest API - AADSTS50034:XXXXX 目录中不存在用户帐户 {EmailHidden}

[英]Power BI Rest API - AADSTS50034: The user account {EmailHidden} does not exist in the XXXXX directory

I'm trying to get an access token instead of getting this error message我正在尝试获取访问令牌而不是收到此错误消息

AdalError: Get Token request returned http error: 400 and server response: {"error":"invalid_grant","error_description":"AADSTS50034: The user account {EmailHidden} does not exist in the XXXXX directory. To sign into this application, the account must be added to the directory.\r\nTrace ID: f18021a8-b10a-40bf-9f0a-7975b38e2300\r\nCorrelation ID: 4f61c8f5-ed06-41f1-8d7b-756dd7c09e10\r\nTimestamp: 2020-12-16 03:27:49Z","error_codes":[50034],"timestamp":"2020-12-16 03:27:49Z","trace_id":"f18021a8-b10a-40bf-9f0a-7975b38e2300","correlation_id":"4f61c8f5-ed06-41f1-8d7b-756dd7c09e10","error_uri":"https://login.windows.net/error?code=50034"}

My python code我的 python 代码

import adal
import json
import pyodbc
import requests

AUTHORITY_URL = 'https://login.windows.net/XXXXX'
RESOURCE = 'https://analysis.windows.net/powerbi/api'
CLIENT_ID = 'XXXXX'
userid='nurdin@xxxxx.com.my'
userpassword='xxxxx'
completedtime = []
verify = []

def make_headers(access_token):
    return {
    'Authorization': 'Bearer {}'.format(access_token)
    }

context = adal.AuthenticationContext(AUTHORITY_URL)
token = context.acquire_token_with_username_password(RESOURCE,userid,userpassword,CLIENT_ID)
access_token = token['accessToken']
print(access_token)

Your code works fine on my side, make sure your work account is under the tenant in the AUTHORITY_URL , if not, you could follow this link to create a new user without MFA-enabled.您的代码在我这边运行良好,请确保您的工作帐户在AUTHORITY_URL的租户下,如果没有,您可以按照此链接创建一个未启用 MFA 的新用户。

import adal

AUTHORITY_URL = 'https://login.windows.net/<tenant-id>'
RESOURCE = 'https://analysis.windows.net/powerbi/api'
CLIENT_ID = '<client-id>'
userid='username@tenantname.onmicrosoft.com'
userpassword='xxxxxx'

context = adal.AuthenticationContext(AUTHORITY_URL)
token = context.acquire_token_with_username_password(RESOURCE,userid,userpassword,CLIENT_ID)
access_token = token['accessToken']
print(access_token)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM