Prerequisites (What You Will Need):
Your Laurel customerId
This is a MongoDB objectId (example:
673d1d000c4ef550678f9d67
)
Your OAuth 2.0 clientId
Your OAuth 2.0 clientSecret
Step 1 (Generate Temporary Token and Query):
Because of how Power BI generates a default query, this step will need to be performed as a one time process.
Follow the developer docs here (https://developer.laurel.ai/guides/authentication)
Navigate to https://www.postman.com/ create a new request and input the following:
Ensure method is set to POST
Add https://identity.laurel.ai/api/v1/oauth/token in the URL bar
Add the following to the JSON body replacing the
<clientId>
and<clientSecret>
:{
"audience": "https://timeautomation.com",
"grant_type": "client_credentials",
"client_id": "<clientId>",
"client_secret": "<clientSecret>"
}
The response should include the
access_token
which can be used in Step 2
Step 2 (Connect To Power BI):
Select the "Web" option when getting data from Power BI
Follow the developer documentation here and select the "Advanced" option: https://developer.laurel.ai/services/time/entries to retrieve entries.
In the URL parts enter:
https://api.laurel.ai/time/api/v2/customers/{customerId}/entries?
where{customerId}
is found in the prerequisites section.In the next box under URL parts enter
updatedAfter=2024-11-18&
In the next box under URL parts enter
updatedOnOrBefore=2024-11-19
In the HTTP request header parameters enter
Authorization
on the left side andBearer <access_token>
whereaccess_token
is the value retrieved in step 1
Select Anonymous for the next step and hit "Connect"
Your data should appear in the Power Query Editor
Step 3 (OAuth 2.0 Authentication):
Currently all entries should be shown under the Power Query Editor and you can retrieve data and any other data you'd like, but your access_token
expires every 24 hours and needs to be regenerated. This step will auto regenerate your access token with OAuth 2.0 Authentication.
Click Blank Query under your new Power Query Editor
In the advanced editor, enter the following:
let
TokenResponse = Json.Document(
Web.Contents(
"https://identity.laurel.ai/api/v1/oauth/token",
[
Content =
Json.FromValue([
audience = "https://timeautomation.com",
grant_type = "client_credentials",
client_id = "<replace with clientId>",
client_secret = "<replace with clientSecret>"
]),
Headers = [
#"Content-type" = "application/json",
#"Method" = "POST"
]
]
)
),
AccessToken = TokenResponse[access_token]
in
AccessToken
If it says: "Please specify how to connect" you can choose Anonymous Authentication
Rename Your Function to
GetToken
like this:Make it a function by adding
() =>
to the start ofGetToken
queryIn the original Query, open the "Advanced Editor" and replace the long
access_token
value with&GetToken()
like what is shown in this pictureIf a privacy setting comes up, check the button to ignore privacy levels. You can read more about what that means here: https://learn.microsoft.com/en-us/power-bi/enterprise/desktop-privacy-levels