hydra-js
Hydra is a runnable server implementation of the OAuth2 2.0 authorization framework and the OpenID Connect Core 1.0.
Hydra-js is a client library for javascript. It is currently available as an npm-module only. At this moment, Hydra-js primarily helps you with performing the consent validation. We welcome contributions that implement more of the Hydra HTTP REST API.
Installation
$ npm i --save hydra-js
Examples
Instantiating
var Hydra = const config = client: id: processenvHYDRA_CLIENT_ID // id of the client you want to use, defaults to this env var secret: processenvHYDRA_CLIENT_SECRET // secret of the client you want to use, defaults to this env var auth: tokenHost: processenvHYDRA_URL // hydra url, defaults to this env var authorizePath: '/oauth2/auth' // hydra authorization endpoint, defaults to '/oauth2/auth' tokenPath: '/oauth2/token' // hydra token endpoint, defaults to '/oauth2/token' scope: 'hydra.keys.get' // scope of the authorization, defaults to 'hydra.keys.get' const hydra = config
Getting an access token with the client_credentials flow
var Hydra = const hydra = /* options */hydra
Consent flow
The following examples fetches the appropriate cryptographic keys and access tokens automatically, you basically need to do:
var Hydra = const hydra = /* options */ // verify consent challengehydra // generate consent challengehydra