accessToken is not returned when successRedirect is set #4

Closed
whollacsek opened this Issue Dec 18, 2016 · 1 comment

Projects

None yet

1 participant

@whollacsek
whollacsek commented Dec 18, 2016 edited

This is more a question then a bug report.

Steps to reproduce

I migrated to feathers-authentication v1 and integrated twitter oauth with feathers-authentication-oauth1, both work well, the problem I'm facing right now is: if I don't setup successRedirect then a page with raw json response (with the accessToken) is returned at the end of oauth flow. On the other hand if a path is set, then there is no way to retrieve the accessToken. I couldn't find any documentation about this behavior.

My config:

{
  "auth": {
    "cookie": {
      "enable": true
    },
    "twitter": {
      "consumerKey": "...",
      "consumerSecret": "..."
    }
  }
}

The auth part on the server looks like this.

const authentication = require('feathers-authentication')
const oauth1 = require('feathers-authentication-oauth1')
const session = require('express-session')
const TwitterStrategy = require('passport-twitter').Strategy

module.exports = function () {
  const app = this
  app.use(session({secret: 'super secret', resave: true, saveUninitialized: true}))
  app.configure(authentication(app.get('auth')))
  app.configure(oauth1({
    name: 'twitter',
    Strategy: TwitterStrategy,
    successRedirect: '/app'
  }))
}

And on the client, on /app:

import feathers from 'feathers-client'
import auth from 'feathers-authentication-client'

const host = 'http://localhost:4040'
const app = feathers()
.configure(feathers.rest(host).fetch(window.fetch.bind(window)))
.configure(feathers.hooks())
.configure(auth({storage: window.localStorage}))

app.authenticate() // does not work because no accessToken is found

Expected behavior

accessToken being set in the response header? So it could be read by feathers client automatically.

Actual behavior

No accessToken is returned.

System configuration

Module versions server:

"express-session": "^1.14.2",
"feathers": "^2.0.3",
"feathers-authentication": "^1.0.2",
"feathers-authentication-oauth1": "^0.2.3",
"passport": "^0.3.2",
"passport-twitter": "^1.0.4",

Module versions web:

"feathers-authentication-client": "^0.1.6",
"feathers-client": "^1.8.0",

NodeJS version: 6.9.2

Operating System: Ubuntu 16.04

Browser Version: Chrome 55

@whollacsek

Ok, found the culprit, the config should be auth.cookie.enabled instead of auth.cookie.enable. Typo in the migration doc

@whollacsek whollacsek added a commit to whollacsek/feathers-authentication that referenced this issue Dec 18, 2016
@whollacsek whollacsek Typo 'cookie.enable' should be 'cookie.enabled' 11ba11a
@whollacsek whollacsek referenced this issue in feathersjs/feathers-authentication Dec 18, 2016
Merged

Typo 'cookie.enable' should be 'cookie.enabled' #380

@whollacsek whollacsek closed this Dec 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment