Skip to content

annotell/kognic-auth-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kognic Authentication

Python 3 library providing foundations for Kognic Authentication on top of the requests or httpx libraries.

Install with pip install kognic-auth[requests] or pip install kognic-auth[httpx]

Builds on the standard OAuth 2.0 Client Credentials flow. There are a few ways to provide auth credentials to our api clients. Kognic Python clients such as in kognic-io accept an auth parameter that can be set explicitly or you can omit it and use environment variables.

There are a few ways to set your credentials in auth.

  1. Set the environment variable KOGNIC_CREDENTIALS to point to your Api Credentials file. The credentials will contain the Client Id and Client Secret.
  2. Set to the credentials file path like auth="~/.config/kognic/credentials.json"
  3. Set environment variables KOGNIC_CLIENT_ID andKOGNIC_CLIENT_SECRET
  4. Set to credentials tuple auth=(client_id, client_secret)

API clients such as the InputApiClient accept this auth parameter.

Under the hood, they commonly use the AuthSession class which is implements a requests session with automatic token refresh. An httpx implementation is also available.

from kognic.auth.requests.auth_session import RequestsAuthSession

sess = RequestsAuthSession()

# make call to some Kognic service with your token. Use default requests 
sess.get("https://api.app.kognic.com")

Changelog

See Github releases from v3.1.0, historic changelog is available in CHANGELOG.md