Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Power BI GET-Methode with token as request header

Hi evereyone I'm new to power bi and I'm trying an OAuth using the GET method. But it's not the conventional way, I think. I can show you the issue with swagger. I get a connection, if i dont fill ...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    I think you can follow the below step to get access token and get data from API.

     

    1. Get Access token in Power BI Desktop:
    () =>
    
     
    
    let
    
        body = "client_id=" & #"App ID"
    
        & "&scope=https://analysis.windows.net/powerbi/api/.default&client_secret=" & #"App Secret"
    
        & "&grant_type=client_credentials",
    
        Data= Json.Document(Web.Contents("https://login.microsoftonline.com/"& TenantID & "/oauth2/v2.0/token/",
    
        [Headers=[#"Content-Type"="application/x-www-form-urlencoded"], Content=Text.ToBinary(body)])),
    
        access_token = Data[access_token]
    
    in
    
        access_token

     

    1. Video: How to get access token and call Rest API by dynamic access token in Power BI Desktop?

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Anonymous's avatar
    Anonymous
    4 years ago

    HI everyone

     

    Sorry for delay, I had to take a little Corona break.

    The solution works fine now, thanks to all.

     

    regards

    Mulder