Skip to main content
All CollectionsLaurel Admin
Connecting to Power BI
Connecting to Power BI
Thomas Zhang avatar
Written by Thomas Zhang
Updated over a month ago

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.

  1. Follow the developer docs here (https://developer.laurel.ai/guides/authentication)

  2. Navigate to https://www.postman.com/ create a new request and input the following:

    1. Ensure method is set to POST

    2. Add the following to the JSON body replacing the <clientId> and <clientSecret>:

      1. {
        "audience": "https://timeautomation.com",
        "grant_type": "client_credentials",
        "client_id": "<clientId>",
        "client_secret": "<clientSecret>"
        }

    3. The response should include the access_token which can be used in Step 2

Step 2 (Connect To Power BI):

  1. Select the "Web" option when getting data from Power BI

  2. Follow the developer documentation here and select the "Advanced" option: https://developer.laurel.ai/services/time/entries to retrieve entries.

    1. In the URL parts enter: https://api.laurel.ai/time/api/v2/customers/{customerId}/entries? where {customerId} is found in the prerequisites section.

    2. In the next box under URL parts enter updatedAfter=2024-11-18&

    3. In the next box under URL parts enter updatedOnOrBefore=2024-11-19

    4. In the HTTP request header parameters enter Authorization on the left side and Bearer <access_token> where access_token is the value retrieved in step 1

  3. Select Anonymous for the next step and hit "Connect"

  4. 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.

  1. Click Blank Query under your new Power Query Editor

  2. In the advanced editor, enter the following:

    1. 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

  3. If it says: "Please specify how to connect" you can choose Anonymous Authentication

  4. Rename Your Function to GetToken like this:

  5. Make it a function by adding () => to the start of GetToken query

  6. In the original Query, open the "Advanced Editor" and replace the long access_token value with &GetToken() like what is shown in this picture

  7. If 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

Did this answer your question?