Git Product home page Git Product logo

token-cli's Introduction

GitHub license GitHub release

TokenCLI

tokenCLI is a command line utility for generating tokens from a OpenID identity provider, such as Keycloak.

tokenCLI uses the Authorization Code Grant Flow, as such a refresh token is generated and used to automatically renew the access token without browser interaction.

token-cli - The OpenID token generator

Installation

OSX

Install:

brew install imduffy15/tap/token-cli

Upgrade:

brew upgrade token-cli

Alternative Installs (tar.gz, RPM, deb, snap)

Check out the releases section on Github for alternative binaries.

Contribute

Fork token-cli and build a custom version. We welcome any useful pull requests.

Usage

Create a new target called example-realm:

$ token-cli target create example-realm -t http://localhost:8080/auth/realms/example-realm/.well-known/openid-configuration

Set example-realm as the active target:

$ token-cli target set example-realm

Get a token for the client "service-template" with redirection port 9090

$ token-cli token get service-template -p 9090

Examples

Google

Add Google as a target and set it as the active target

$ token-cli target create google --openid-configuration-url https://accounts.google.com/.well-known/openid-configuration
$ token-cli target set google

Generate a token for client-id 571394967398-j6vs98u325la013f0ho6hehosdi2h2eb.apps.googleusercontent.com with scope openid

$ token-cli token get 571394967398-j6vs98u325la013f0ho6hehosdi2h2eb.apps.googleusercontent.com --scope openid

You can register Google clients at https://console.cloud.google.com/apis/credentials

Microsoft

Add Microsoft as a target and set it as the active target

$ token-cli target create microsoft --openid-configuration-url https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration
$ token-cli target set microsoft

Generate a token for client-id b9951982-9e22-4bb8-8632-436f47b030f4

$ token-cli token get b9951982-9e22-4bb8-8632-436f47b030f4 --client_secret '[email protected][4LH2mRs@/bH'

You can register Microsoft clients at https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps , this target is for (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox) authorization only.

Azure AD

Add Azure AD as a target, where 960a630a-dab4-4fd9-a048-88eddede726d is my tenant id and set it as the active target

$ token-cli target create azure --openid-configuration-url https://login.microsoftonline.com/960a630a-dab4-4fd9-a048-88eddede726d/v2.0/.well-known/openid-configuration
$ token-cli target set azure

Generate a token for client-id 90a49166-df3b-46a9-bb20-155f4055ef83

$ token-cli token get 90a49166-df3b-46a9-bb20-155f4055ef83 --client_secret 'pGw]yxRb:fww-fk?X2uskpfSPlHXV559'

You can register Azure AD clients at https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps , this target is for (Default Directory only - Single tenant) authorization only.

Okta

Add Okta as a target and set it as the active target

$ token-cli target create okta --openid-configuration-url https://dev-351390-admin.oktapreview.com/.well-known/openid-configuration
$ token-cli target set okta

Generate a token for client-id 0oaodg6in82hvS2uV0h7

$ token-cli token get 0oaodg6in82hvS2uV0h7 --client_secret '8XojWRVjegSMh8hzmZZ-NIq-9ur6fauRDPk-Rv-k'

You can register OKTA clients in your personal dashboard at https://TENANT-ID-admin.oktapreview.com/admin/apps/active , where tenant-id is your tenant id.

Instagram

Add Instagram as as target and set it as the active target

$ token-cli target create instagram --token-url https://api.instagram.com/oauth/access_token --authorization-url https://api.instagram.com/oauth/authorize
$ token-cli target set instagram

Generate a token for client-id c3b3514c9a614b53b6f393b7dc3f7459

$ token-cli token get c3b3514c9a614b53b6f393b7dc3f7459 --client_secret 4dfdef8221284c2480c8d71cea00d0b2  --scope basic

You can register Instagram clients at https://www.instagram.com/developer/clients/manage/

Strava

$ token-cli target create strava --token-url https://www.strava.com/oauth/token --authorizaion-url http://www.strava.com/oauth/authorize
$ token-cli target set strava

Generate a token for client-id 40638

token-cli token get 40638 --client_secret e36b1089bfe26c8010cd10eabe419c96493c412b --scope read

You can register Strava clients at https://www.strava.com/settings/api

Help

$ token-cli --help
Token Command Line Interface, version

Usage:
  token-cli [command]

Available Commands:
  help        Help about any command
  target      Configure and view OIDC targets
  token       Configure and view tokens

Flags:
  -h, --help      help for token-cli
  -v, --verbose   See additional info on HTTP requests

Use "token-cli [command] --help" for more information about a command.
$ token-cli target --help
Configure and view OIDC targets

Usage:
  token-cli target [flags]
  token-cli target [command]

Available Commands:
  create      Creates a new target
  delete      Delete the target named TARGET_NAME
  get         View the target named TARGET_NAME
  list        List all targets
  set         sets TARGET_NAME as active

Flags:
  -h, --help                  help for target
  -k, --skip-ssl-validation   Disable security validation on requests to this target

Global Flags:
  -v, --verbose   See additional info on HTTP requests

Use "token-cli target [command] --help" for more information about a command.
$ token-cli token --help
Configure and view tokens

Usage:
  token-cli token [command]

Available Commands:
  get         Obtain a token for the specified CLIENT_ID

Flags:
  -h, --help   help for token

Global Flags:
  -v, --verbose   See additional info on HTTP requests

Use "token-cli token [command] --help" for more information about a command.

License

Apache License 2.0

token-cli's People

Contributors

ian-duffy-wd avatar imduffy15 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

token-cli's Issues

Brew installation failure

Hello

I am on WIndows, using WSL2 with Ubuntu distribution. In general - consider this as a regular Ubuntu.

When trying ton install token-cli - I got following.

 brew install imduffy15/tap/token-cli
Running `brew update --preinstall`...
==> Auto-updated Homebrew!
Updated Homebrew from 3.4.10 (30e3d8883) to 3.4.11 (87bcd1935).
Updated 2 taps (homebrew/core and tilt-dev/tap).
==> Updated Formulae
Updated 10 formulae.


==> Homebrew was updated to version 3.4.11
The changelog can be found at:
  https://github.com/Homebrew/brew/releases/tag/3.4.11
==> Tapping imduffy15/tap
Cloning into '/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/imduffy15/homebrew-tap'...
remote: Enumerating objects: 112, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 112 (delta 0), reused 0 (delta 0), pack-reused 108
Receiving objects: 100% (112/112), 12.95 KiB | 1020.00 KiB/s, done.
Resolving deltas: 100% (26/26), done.
Error: Invalid formula: /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/imduffy15/homebrew-tap/Formula/token-cli.rb
token-cli: Calling bottle :unneeded is disabled! There is no replacement.
Please report this issue to the imduffy15/tap tap (not Homebrew/brew or Homebrew/core):
  /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/imduffy15/homebrew-tap/Formula/token-cli.rb:6

Error: Cannot tap imduffy15/tap: invalid syntax in tap!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.