Last Updated:
December 15, 2021
by
Kayleigh LeBlanc
| Version: 5
| 2,553 views
| 1 follower
members are following updates on this item.
When using any of the Igloo APIs to develop your integration or application, you must first be authenticated with you’re the digital workplace you are developing on. To authenticate means that one entity has proven its identity to the other party. This proves that you are who you are, serving as an identification card.
Following are the steps that need to be followed to ensure that you are successful authenticating:
def session_create(self, app_id, app_password, username, password): """ Creates a session with your IGLOO Digital Workplace - V1 :return: Token Id - used to create subsequent API calls """ url = "{}/.api/api.svc/session/create".format(self.url) params = { "appId": app_id, "appPass": app_password, "username": username, "password": password, "community": "https://yourdigitalworkplaceurl.ca/", "apiversion": 1 } try: print(url) request = requests.post(url, params=params, headers={'accept': 'application/json'}) response = request.json() print(response) return response['response']['sessionKey'] except exceptions.HTTPError as err_http: print(str(err_http)) except exceptions.ConnectionError as err_connection: print(str(err_connection))
What if I am authentication using the V2 API?
def session_create(self, app_id, app_password, username, password): """ Creates a session with your IGLOO Digital Workplace - V2 :return: Token Id - used to create subsequent API calls """ url = "{}/.api2/api/v{}/session/create".format(self.url, self.api_version) # The Session Create V1 endpoint enables a user to get a session. # Compared to the unversioned endpoint, # this one supports authentication via LDAP and Igloo credentials. params = { "AppID": app_id, "AppPassword": app_password, "UserName": username, "UserPassword": password, "ApiVersion": 1, "Instance": 0 } try: request = requests.post(url, data=params, headers={'accept': 'application/json'}) response = request.json() print(response) return response["TokenId"] except exceptions.HTTPError as err_http: print(str(err_http)) except exceptions.ConnectionError as err_connection: print(str(err_connection))
A Session Key or a Token ID is returned as a result of these API calls. Both confirm that you have been authenticated properly. For any subsequent API calls, you must pass this Session Key or the Token ID as a cookie in your header so that Igloo can validate and authenticate every single API call that is made in the future. Here is more information on how to make subsequent API calls.