Forum Discussion

prodoreda's avatar
prodoreda
Frequent Visitor
4 years ago
Solved

Power BI and Personio API: Dynamic single-use token

Hey all!  First post here 🙂 I'm trying to connect our Personio account API as a data source for our Power BI. Context is, Personio API requires a CLIENT_ID and a SECRET whit which generates a sin...
  • prodoreda's avatar
    prodoreda
    4 years ago

    Hey, thanks for your reply Anonymous !!

    I was able to spare some time during the weekend and four a way to make it work:
    let
    Source = let
    body = "{""client_id"":""XXXXXXX"",""client_secret"":""ZZZZZZZ""}",
    Data= Web.Contents("https://api.URL.com/auth?",[Content=Text.ToBinary(body),Headers=[#"Content-Type"="application/json"]]),
    DataRecord = Json.Document(Data),
    Bearer=DataRecord[data][token],
    bearerBody = Web.Contents( "https://api.URL.de/v1/company?",[Headers=[#"Accept"="application/json",#"Authorization"="Bearer "&Bearer]]),
    employees = Json.Document(bearerBody)

    in
    employees

    Basically I captured the response in a variable, then replicated the first call, changing the headers to include the "Authorization" and passing the variable to it.

    So far is still working with every refresh.

    I´ll check also your solution to see which one is faster 🙂

    Thanks!