Get an access token with basic authentication - Intergraph Smart Completions - Intergraph Smart Completions Update 4 - Customization & Programming

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

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 PBIX templates! The credentials stored in the token function will allow anyone to access data, including data stored in other applications and shared with Smart Completions.

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

    13 - Authorization Code with PKCE 1

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

    14 - Authorization Code with PKCE 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.

  5. Change the query name to GetToken, and select 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

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

  4. Select Done.

    The query automatically generates a token and loads the data.