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

Providing token to feathers.authentication doesn't work #230

Closed
combsco opened this Issue Jul 4, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@combsco
Copy link

combsco commented Jul 4, 2016

const feathers = require('feathers-client')
const fetch = require('node-fetch')

const token = 'very.long.token'

const host = 'http://lvh.me:3000'
const api = feathers()
          .configure(feathers.hooks())
          .configure(feathers.rest(host).fetch(fetch))
          .configure(feathers.authentication({type: 'token', token}))

api.service('assets').find({}).then((assets) => {
  console.log('Assets!', assets)
})
.catch((error) => { console.log(error) })

Server responds with missing authentication token.

@daffl

This comment has been minimized.

Copy link
Member

daffl commented Jul 4, 2016

You have pass the options to app.authenticate not during configuration:

const feathers = require('feathers-client')
const fetch = require('node-fetch')

const token = 'very.long.token'

const host = 'http://lvh.me:3000'
const api = feathers()
          .configure(feathers.hooks())
          .configure(feathers.rest(host).fetch(fetch))
          .configure(feathers.authentication({
            storage: window.localStorage
          }))

api.authenticate({ type: 'token', token }).then(data => {
  api.service('assets').find({}).then((assets) => {
    console.log('Assets!', assets)
  })
  .catch((error) => { console.log(error) })
})
@combsco

This comment has been minimized.

Copy link
Author

combsco commented Jul 4, 2016

Alright thanks @daffl that worked. Didn't know it wasn't supposed to be in configuration.

@combsco combsco closed this Jul 4, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.