Skip to content
This repository was archived by the owner on Mar 22, 2022. It is now read-only.

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

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

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

combsco opened this issue Jul 4, 2016 · 2 comments

Comments

@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
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
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 as completed Jul 4, 2016
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants