Forum Discussion
amatteo90
7 years agoNew Member
Native App for data push with auto login
Hello everyone, I'm building a console application using Visual Studio 2017 in order to push data into a Power BI dataset. I followed this guide: https://docs.microsoft.com/en-us/power-bi/develope...
v-jiascu-msft
7 years agoMicrosoft Employee
Hi amatteo90,
How did you try to get the token? Since there are many methods, the process of authentication depends on your code. Please refer to the Python script below, which use a username and a password to get the access token.
We can get the token for both Native App and Web App unless the AAD requires two-factor authentication.
Reference: azure-activedirectory-library-for-python and active-directory/develop/v1-oauth2-implicit-grant-flow.
# adal is azure-activedirectory-library-for-python. install it first.
from adal import AuthenticationContext
# get access token implictly with username and password.
def get_token():
client_id = "a30***1ae1dcde27e"
resource_uri = "https://analysis.windows.net/powerbi/api"
user_name = "d**.com"
user_password = "password"
auth_context = AuthenticationContext("https://login.microsoftonline.com/your_tenant_name")
token_response = auth_context.acquire_token_with_username_password(resource_uri, user_name, user_password, client_id)
token = "Bearer " + token_response["accessToken"]
return token
Best Regards,
Dale
tripleacoder
7 years agoHelper I
I think your answer is unrelated to the problem of authorization, since it only talks about authentication.