Products | Versions |
---|---|
TIBCO Data Virtualization | 8.7, 8.6 |
In the given scenario, Anaconda Python, an open-source platform, is utilized for scripting and executing code in Python for this KB.
Prerequisites:
All Supported Environment
import requests # URL and payload for obtaining access token token_url = "https://login.microsoftonline.com/81b0c56e-5c46-4d31-a99f-c43d1613fe7d/oauth2/token" headers = { "content-type": "application/x-www-form-urlencoded" } data = { "grant_type": "client_credentials", "client_id": "provide the client ID here", "client_secret": "provide the client secret here", "resource": "provide the resource details here" } # Obtaining access token token_response = requests.post(token_url, data=data) token_data = token_response.json() access_token = token_data['access_token'] # URL for accessing the API api_url = "provide the API URL hosted in TDV here" myHeaders = { 'Authorization': f'Bearer {access_token}' } # Making GET request to the API response = requests.get(api_url, headers=myHeaders) print(response.text)
This article demonstrates Python code functioning as a client app. It obtains the access token and also makes a call to the published resource in TDV to retrieve the results.