A client library for talking with the BYU ORY Hydra instance
Last updated a year ago by gi60s .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @byu-oit/hydra-client 
SYNC missed versions from official npm registry.

Hydra Client

This package includes a functional API for making requests against BYU's ORY Hydra implementation.


npm install @byu-oit/hydra-client



new HydraClient (config): Object

Constructs a HydraClient instance.


  • config - A required configuration object with the following required properties:

    • baseUrl - The base URL to use to connect to the hydra server.

    • clientId - The client ID to use to access administrative features on the hydra server.

    • clientSecret - The client secret to use to access administrative features on the hydra server.

Returns an instance of the BYU Hydra Client.


const HydraClient = require('@byu-oit/hydra-client')
const client = new HydraClient({
  baseUrl: 'https://my-hydra-domain.com:4455',
  clientId: 'client_id',
  clientSecret: 'a super secret secret'



authorizationMiddleware (options): Function

Produce an express middleware function that will look for authorization credentials, validate and decode them, and attach them to the request object as the oauth property. The value attached to the oauth property is the same as that returned by calling the introspection function.


  • options - An object with these properties:

    • authorizationRequired - Whether the middleware requires authorization. If set to true then a valid authorization bearer token must be provided. If set to false then the authorization header may be omitted. Regardless of this setting, if an authorization header is provided then it must be valid. Defaults to true.

    • fallthrough - Set to true to have authorization errors call the next error handling middleware. If set to false then a response will be sent instead. Defaults to false.

Returns a middleware function.


const app = express()
const client = new HydraClient(config)


app.get('/', (req, res) => {
  if (req.oauth.user) {
    res.send('You are using a code grant token')
  } else {
    res.send('You are using a client grant token')



introspection (token): Promise<Object>

Introspect a token to determine the client information, user information (where applicable), and scopes.


  • token - An access token to get introspection from.

Returns A promise that resolves to an object with these properties:

  • client - An object containing client information, including:

    • id - The client ID.

    • owner - The client owner name.

  • scopes - An array of the scopes granted to the token.

  • user - An object containing user information. This property only exists when a user is tied to the token. Includes the properties:

    • ces_id - The CES id of the user


const client = new HydraClient(config)
  .then(introspection => {
      client: {
        id: 'client-id',
        owner: 'owner-name'
      scopes: [ 'scope-one', 'scope-two' ],
      user: {
        ces_id: '123456789'

Current Tags

  • 0.0.5                                ...           latest (a year ago)

4 Versions

  • 0.0.5                                ...           a year ago
  • 0.0.4                                ...           a year ago
  • 0.0.3                                ...           a year ago
  • 0.0.2                                ...           a year ago
Today 0
This Week 0
This Month 5
Last Day 0
Last Week 4
Last Month 0
Dependencies (3)
Dev Dependencies (3)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |