Knowledge Drop

The "How To" on initializing the SDK with different profiles in your ini file

  • 7 July 2021
  • 0 replies
  • 102 views

Userlevel 4

Last tested: May 13, 2020
 

For those that don't know, the ini file contains information like client secret and id that help us determine which user/profile to initialize the SDK with. Additionally you can have multiple profiles defined in a single ini file by adding the profile name in [example] above the credentials for that profile.

Now the question becomes, how can one initialize the SDK based off of a specific profile they have defined in their ini file? Well that is actually quite simple

INI File:

[somethingelse]

# API version is required

api_version=3.1

# Base URL for API. Do not include /api/* in the url

base_url=https://localhost:19999

# API 3 client id

client_id=...

# API 3 client secret

client_secret=...

# Set to false if testing locally against self-signed certs. Otherwise leave True

verify_ssl=False

 

[Looker]

# API version is required

api_version=3.1

# Base URL for API. Do not include /api/* in the url

base_url=https://instance.looker.com:19999

# API 3 client id

client_id=...

# API 3 client secret

client_secret=...

# Set to false if testing locally against self-signed certs. Otherwise leave True

verify_ssl=True

 

SDK Initialization:

# Initializing with the [Looker] profile

sdk = looker_sdk.init31(config_file="looker_instance.ini", section="Looker")

Here we are passing a config_file parameter pointing to the ini file. Then we are passing in a section parameter which references the section or profile in the ini file with which's credentials you want the SDK to be initialized with!

And that's all she wrote!

 

This content is subject to limited support.                

 

 


0 replies

Be the first to reply!

Reply