Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User-Based Authentication Capabilities #9

Conversation

sha1sum
Copy link
Contributor

@sha1sum sha1sum commented Nov 18, 2016

This provides support for user-based authentication with email and password credentials, where either credentials with publicKey/privateKey or email/password are supported when creating the API. .on('auth', ...) still functions properly, and clients must call api.auth() in order to authenticate. Example:

import createApi from 'forte-api'
import os from 'os'

const scope = {
  hostname : os.hostname(),
  trunk    : trunkID,
}
const creds = {
  email    : 'some@body.com',
  password : 'mysupersecretpassword',
}

const api = createApi(creds, scope, {url: 'http://api.powerchord.io'})

api.on('auth', (err, token) => {
  if (err) {
    // ...
  }
  creds.bearerToken = token
})

api.auth().then(() => {
  // ...
})

Some of the documentation was also inaccurate and has been fixed to the best of my ability. Most of it was replacing ForteApi with createApi.

@mvandiest mvandiest merged commit e186eb9 into powerchordlabs:master Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants