Skip to main content

Used to fetch OKTA tokens for an application using web a browser that redirects to a commandline server

Project description

okta-token-fetcher

Provides a commandline script and package for getting an OKTA id_token by interacting with your browser via the commandline.

This script builds off of the dirty quick way to get a token from your browser stated here: https://developer.okta.com/docs/guides/implement-oauth-for-okta/main/#get-an-access-token-and-make-a-request .

This is done by opening a browser window that navigates to the auth server with localhost as the redirect_uri. There is an http server that is spun up for just long enough to handle the redirect request and get the id_token from the query parameters that are sent via window.hash (I suppose OKTA does this so that it can't be sent to the server itself).

Note that when using this tool your OKTA JWT will:

  • Be stored in ~/.okta_token (700 file permissions) unless --no-cache is specified
  • Be visible in the url bar of your browser for a few seconds
  • Be visible on the page after all of the redirects for 3 seconds before being redirected to a final page in your browser

Your OKTA application MUST have "http://localhost:8888" configured as one of the allowed redirect uri's for this tool to work.

As a terminal script:

usage: okta-fetch [-h] -u URL -c CLIENT_ID [-s SCOPES] [-t TOKEN_TYPE] [--no-cache]

optional arguments:
  -h, --help            show this help message and exit
  -u URL, --url URL     The auth server url. This should be only the domain and protocol. eg: https://mydomain.okta.com
  -c CLIENT_ID, --client-id CLIENT_ID
                        The client id to get a token for
  -s SCOPES, --scopes SCOPES
                        Comma delimited list of scopes to request
  -t TOKEN_TYPE, --token-type TOKEN_TYPE
                        The type of token to request
  --no-cache            Don't cache the token

Implemented in another script:

fetcher = OktaToken(
    url="https://youraccount.okta.com",
    client_id="abcdefg12345",
    scopes=["groups", "profile"],
    token_type="id_token",
    cache=True
)

print(fetcher.token)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

okta-token-fetcher-0.0.3.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

okta_token_fetcher-0.0.3-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file okta-token-fetcher-0.0.3.tar.gz.

File metadata

  • Download URL: okta-token-fetcher-0.0.3.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9

File hashes

Hashes for okta-token-fetcher-0.0.3.tar.gz
Algorithm Hash digest
SHA256 623021ab90b6f29c5ccc8956b931c25a85ecff9e7446ca4d53085a4847b46d2e
MD5 6338c092142ec68e3bfa1a2c81e376c2
BLAKE2b-256 e6a42fe5efc7bb07d880b5f56990ab2de968ff35500acfe532e9f70f9a71d139

See more details on using hashes here.

File details

Details for the file okta_token_fetcher-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: okta_token_fetcher-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9

File hashes

Hashes for okta_token_fetcher-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 90ce206e9e2749771895ff9dd49f0b855790f8d32836c1aaf939a56e4bb6d9c4
MD5 44dd3df0a9d38b7fcd63f4c930b54eb0
BLAKE2b-256 5594fa3160fc32de9a5bb9b252d29d54503d29e2cc1f1a543e0215be035957d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page