BigID API/User Authentication: Difference between revisions
(Created page with "In this tutorial, we're going to authenticate with BigID using Username/Password auth and retrieve a list of data sources. Below you'll see the POST request we'll use to authenticate. The body of the request contains our username and password and we're directing the request to the sessions endpoint in our BigID Sandbox system. Press {{Key|Send}} to get a session token. <html> <iframe style="border:0px; width:100%; height:400px; border-radius:10px;" src="https://apibrow...") |
No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
In this tutorial, we're going to authenticate with BigID using Username/Password auth and retrieve a list of data sources. | In this tutorial, we're going to authenticate with BigID using Username/Password auth and retrieve a list of data sources. | ||
=== Getting a session token === | |||
Below you'll see the POST request we'll use to authenticate. The body of the request contains our username and password and we're directing the request to the sessions endpoint in our BigID Sandbox system. Press {{Key|Send}} to get a session token. | Below you'll see the POST request we'll use to authenticate. The body of the request contains our username and password and we're directing the request to the sessions endpoint in our BigID Sandbox system. Press {{Key|Send}} to get a session token. | ||
<html> | <html> | ||
<iframe style="border:0px; width:100%; height:400px; border-radius:10px;" src="https:// | <iframe style="border:0px; width:100%; height:400px; border-radius:10px;" src="https://apiexplorer.bigid.tools/?url=sessions&method=POST&body=%7B%22username%22%3A%22bigid%22%2C%22password%22%3A%22learner%22%7D&selectedSetting=body"></iframe> | ||
</html> | </html> | ||
Line 23: | Line 25: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Calling an API == | === Calling an API === | ||
Now that you have a session token we can directly call BigID APIs. Documentation for these APIs is available at https://www.docs.bigid.com/bigid/reference/api-getting-started . Since we're just trying to perform a simple task, we don't need the docs here, just to know that GET /ds-connections is the endpoint to retrieve a list of data source connections. | Now that you have a session token we can directly call BigID APIs. Documentation for these APIs is available at https://www.docs.bigid.com/bigid/reference/api-getting-started . Since we're just trying to perform a simple task, we don't need the docs here, just to know that GET /ds-connections is the endpoint to retrieve a list of data source connections. | ||
Line 30: | Line 32: | ||
<html> | <html> | ||
<iframe style="border:0px; width:100%; height:400px; border-radius:10px;" src="https:// | <iframe style="border:0px; width:100%; height:400px; border-radius:10px;" src="https://apiexplorer.bigid.tools/?url=ds-connections&method=GET&selectedSetting=headers"></iframe> | ||
</html> | </html> | ||
Latest revision as of 18:48, 4 March 2022
In this tutorial, we're going to authenticate with BigID using Username/Password auth and retrieve a list of data sources.
Getting a session token
Below you'll see the POST request we'll use to authenticate. The body of the request contains our username and password and we're directing the request to the sessions endpoint in our BigID Sandbox system. Press Send to get a session token.
In the response, there's a bunch of information about the logged in user. For our purposes, we just care about line 4, the auth_token. This token is what we'll use the authenticate with the other BigID APIs. We've placed a sample below with the auth token highlighted. Copy the auth token from the request you placed above. We'll need it in just a second.
{
"success": true,
"message": "Enjoy your token!",
"auth_token": "eyJhbGciOiJ<don't copy me! I'm just an example!>...",
"username": "bigid",
"firstName": "BigID Admin",
"permissions": [
"admin",
"permission.tasks.edit",
"permission.tasks.read_task_list",
...
Calling an API
Now that you have a session token we can directly call BigID APIs. Documentation for these APIs is available at https://www.docs.bigid.com/bigid/reference/api-getting-started . Since we're just trying to perform a simple task, we don't need the docs here, just to know that GET /ds-connections is the endpoint to retrieve a list of data source connections.
Add a new header named "Authorization" and paste the session token you got in the previous request to authenticate yourself.
In that API call, we can see a list of data sources and all the information for each data source.
{
"status": "success",
"statusCode": 200,
"data": {
"ds_connections": [
"<data source info here>"
]
}
}
We now know the API calls we need and can use our programming language of choice to prepare our report. Below are some samples.
import fetch from 'node-fetch';
let credentials = { username: "bigid", password: "learner" };
let env = "https://sandbox.mybigid.com/";
async function getDataSources(credentials, env) {
// Request API Key using user/pass authentication
const sessionRequest = fetch(env + 'api/v1/sessions', {
method: 'POST',
body: JSON.stringify(credentials),
headers: { 'Content-Type': 'application/json' }
});
const sessionData = await request.json();
const dsRequest = fetch(env + 'api/v1/ds-connections', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': sessionData.auth_token
}
});
return await dsRequest.json();
}
let credentials = { username: "bigid", password: "learner" };
let env = "https://sandbox.mybigid.com/";
async function getDataSources(credentials, env) {
// Request API Key using user/pass authentication
const sessionRequest = window.fetch(env + 'api/v1/sessions', {
method: 'POST',
body: JSON.stringify(credentials),
headers: { 'Content-Type': 'application/json' }
});
const sessionData = await request.json();
const dsRequest = window.fetch(env + 'api/v1/ds-connections', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': sessionData.auth_token
}
});
return await dsRequest.json();
}
import requests
credentials = {'username':'bigid', 'password':'learner'}
env = 'https://sandbox.mybigid.com/'
def getDataSources(credentials, env):
sessionRequest = requests.post(env+'api/v1/sessions', data = credentials)
sessionData = sessionRequest.json()
dsRequest = requests.get(env+'api/v1/ds-connections', headers = {'Authorization':sessionData.get('auth_token')})
return dsRequest.json()