Fortinet white logo
Fortinet white logo

Python examples

Python examples

Getting access token
import requests


client_id = 'ec601e2a-73bbxxxxxxxx' client_secret = 'mRR6ciFnKxxxxxxxxx'

payload = {
'client_id': client_id, 'client_secret': client_secret
}

resp = requests.request('post', 'https://fic.fortinet.com:9696/api/v1/login', json=payload, verify=False)

access_token = resp.json()['access_token']
Getting a list of all users with access token
import requests


headers = {
'Authorization': 'Bearer eyJ0ex*******Q6to', 'Content-Type': 'application/json'
}

payload = {}

resp = requests.request('get', 'https://fic.fortinet.com:9696/api/v1/user/base', headers=headers, json=payload, verify=False)
Assigning new token for user with access token
import requests headers = {
‘Authorization’: ‘Bearer eyJ0ex*******Q6to’, ‘Content-Type’: ‘application/json’

payload = {
'change_token': true,
}
resp = requests.request('put', 'https://fic.fortinet.com:9696/api/v1/user/[input user reference ID here]', headers=headers, json=payload, verify=False)

Python examples

Python examples

Getting access token
import requests


client_id = 'ec601e2a-73bbxxxxxxxx' client_secret = 'mRR6ciFnKxxxxxxxxx'

payload = {
'client_id': client_id, 'client_secret': client_secret
}

resp = requests.request('post', 'https://fic.fortinet.com:9696/api/v1/login', json=payload, verify=False)

access_token = resp.json()['access_token']
Getting a list of all users with access token
import requests


headers = {
'Authorization': 'Bearer eyJ0ex*******Q6to', 'Content-Type': 'application/json'
}

payload = {}

resp = requests.request('get', 'https://fic.fortinet.com:9696/api/v1/user/base', headers=headers, json=payload, verify=False)
Assigning new token for user with access token
import requests headers = {
‘Authorization’: ‘Bearer eyJ0ex*******Q6to’, ‘Content-Type’: ‘application/json’

payload = {
'change_token': true,
}
resp = requests.request('put', 'https://fic.fortinet.com:9696/api/v1/user/[input user reference ID here]', headers=headers, json=payload, verify=False)