Get an access token for Power BI using the Basic Authentication grant type - Intergraph Smart Completions - Intergraph Smart Completions 6.0 - Customization & Programming - Hexagon

Intergraph Smart Completions Smart API Programmer's Getting Started Guide

Language
English
Product
Intergraph Smart Completions
Search by Category
Customization & Programming
Smart Completions Version
6.0

This example shows how to get an access token for a Power BI client application when using the Basic Authentication grant type.

Required information

Create a query to get an access token

Be extremely cautious about sharing any PBIX template created! The credentials stored in the token function will allow anyone access to your company's data, and that access might not be limited to data stored in Smart Completions.

  1. In the Power BI desktop tool create a blank query.

    9 - Connecting Power BI to Smart Completions Smart API 1

  2. Right-click the query and select Advance Editor.

    10 - Connecting Power BI to Smart Completions Smart API 2

  3. Copy and paste the following code into the blank query:

    ()=>let

    url ="https://<hostname>/api/Authentication.asmx/Authenticate",

    headers = [#"Content-Type" = "application/json"],

    postData = Json.FromValue([

    providerURL = "<hostname>",

    UserName = "joe",

    Password = "joe123",

    ip= "0.0.0.1",

    isMobile= 0]

    ),

    response = Web.Contents(

    url,

    [

    Headers = headers,

    Content = postData

    ]

    ),

    Data = Json.Document(response),

    access_token=Data[d][AuthToken]

    in

    access_token

  4. Replace <hostname> (for url and providerURL), UserName , and Password with your information.

    Power BI Basic Authentication - Get Token Example

  5. Change the query name to GetToken and click Done.

    16 - Authorization Code with PKCE 4

Use the query to get the access token

  1. Create a second blank query for getting the token using the above GetToken function.

  2. Copy and paste the following code into the blank query:

    let

    Source = OData.Feed(https://<hostname>/sc/datalake/v1,[Authorization="Bearer "&GetToken()],[MoreColumns=true])

    in

    Source

    12 - Connecting Power BI to Smart Completions Smart API 4

  3. Replace the <hostname> placeholder with your hostname.

  4. Click Done.

    The query automatically generates a token and loads the data.