Skip to main content
Announcements
Customer Spotlight: Discover what’s possible with embedded analytics Oct. 16 at 10:00 AM ET: REGISTER NOW

Qlik Cloud: Test API calls through OAuth Client with PowerShell

100% helpful (1/1)
cancel
Showing results for 
Search instead for 
Did you mean: 
Damien_V
Support
Support

Qlik Cloud: Test API calls through OAuth Client with PowerShell

Last Update:

Nov 6, 2023 3:57:53 AM

Updated By:

Sonja_Bauernfeind

Created date:

Nov 6, 2023 3:17:33 AM

In Qlik Cloud, it's possible to use OAuth authentication to call Qlik Cloud APIs.

This article explains how to verify that the OAuth client setup has been done correctly by requesting the OAuth token manually to perform the API call.

Details regarding how to set up the OAuth client are available on qlik.dev:

Steps:

  1. Request the OAuth token using the client ID and client secret:
    $hdrs = @{}
    
    $token_endpoint='https://xxx.ap.qlikcloud.com/oauth/token'
    
    $clientid='bcefef34f5a6eexxxxxx2d19'
    $clientsecret='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    
    $body = @{  client_id=$clientid
        client_secret=$clientsecret
        grant_type="client_credentials"
    }|ConvertTo-Json -Compress
    
    $response = Invoke-WebRequest -Uri $token_endpoint -Method Post -Body $body -Headers $hdrs -ContentType 'application/json'
    echo $response.Content​

    The following response is returned:

    {"access_token":"eyJhbGciOiJFUzM4NCIsI....bSht2erUewkKzixaVVn6W1OOXpHlHGAGmiY9cb_obw1FyJ9egEIErjW3cZPdZ3GAfgrQy_NnQg6g1a6lO5y8vhdKj5-zM7RhTXpzPxpzUfeDwBvy
    yj9c3MclcMp1IfDx","token_type":"bearer","expires_at":"2023-09-06T08:29:58.000Z","expires_in":21600}

    Extract the access_token for use in the next step. 

  2. Call an API endpoint to ensure the token is working:

    $hdrs = @{}
    $hdrs.Add("Authorization","Bearer eyJhb...hC1fTY4v3OAyj8Ef6SUQft6-Gd8e86o-NHeprBh19HBK5aBzyFUjlhUSSo8OO4DVieTsKryvCNbBSYEP4NNdgfBKXPmNH1EtbpehAku9rXXbFwPYNH27iinCStlR8W")
    $url = "https://xxx.ap.qlikcloud.com/api/v1/users"
    Invoke-RestMethod -Uri $url -Method Get -Headers $hdrs

 

 

Environments:

Qlik Cloud 

Labels (1)
Version history
Last update:
‎2023-11-06 03:57 AM
Updated by: