Feathers: no callback from app.authenticate

Created on 27 Nov 2019  路  8Comments  路  Source: feathersjs/feathers

Hi guys,

I encountered no callback from app.authenticate

npm setup:

"@feathersjs/authentication-client": "^1.0.8",
"@feathersjs/feathers": "^3.2.3",
"@feathersjs/primus-client": "^1.1.6",
"@feathersjs/socketio-client": "^1.1.5",
 "socket.io-client": "^2.1.1"

feathers.js setup:

import io from 'socket.io-client';
import feathers from '@feathersjs/feathers';
import socketio from '@feathersjs/socketio-client';
import authentication from '@feathersjs/authentication-client';

const socket = io('http://192.168.0.148:3030/');

const app = feathers();

app.configure(socketio(socket));
app.configure(authentication({
  storage: window.localStorage
}));

export default app;

By the way, app.service('model').find() works fine.

Is there any thing I'm missing?

All 8 comments

Hi guys,

I think this has to be related to AsyncStorage from react-native itself.

Somehow, I able to get it work by below feathers setup:

import io from 'socket.io-client';
import feathers from '@feathersjs/feathers';
import socketio from '@feathersjs/socketio-client';
import auth from '@feathersjs/authentication-client';
import { AsyncStorage } from "react-native"
const socket = io('http://192.168.0.148:3030/');

const app = feathers();

app.configure(socketio(socket));
app.configure(auth({ storage: AsyncStorage }));

export default app;

Reopen because after authenticate successfully, hitting 'No auth token'

Still looking for solution

I am facing the same issue

Please upgrade to the latest version and provide a complete example to reproduce if you are still facing the same issue.

hi @daffl

after updating to latest version:

"@feathersjs/authentication-client": "^4.4.1",
"@feathersjs/feathers": "^4.4.1",
"@feathersjs/socketio-client": "^4.4.1",
"socket.io-client": "^2.3.0",
"react-native": "0.61.5",
"react": "16.9.0",

Still not working

Below is my feathers.js setup:

import io from 'socket.io-client';
import feathers from '@feathersjs/feathers';
import socketio from '@feathersjs/socketio-client';
import auth from '@feathersjs/authentication-client';
import { AsyncStorage } from "react-native"
const socket = io('http://192.168.0.118:3030/');
const client = feathers();

client.configure(socketio(socket));

client.configure(auth({
  storage: AsyncStorage,
}));

export default client;

My App.js:

client.authenticate({
     strategy: 'facebook',
     access_token: token
})
.then((res)=>{
     return client.service('users').find()
})
.then((res)=>{
    console.log({res})
})
.catch((err)=>{
    console.log({err})
})

This still giving me the error "No auth token"

By the way, I tried to use the returned token with axios, it works:

client.authenticate({
     strategy: 'facebook',
     access_token: token
})
.then((res)=>{
    return axios.get(`http://192.168.0.118:3030/users`,
            {
              headers:
              {
                'Authorization': res.accessToken
              }
            }
      )
})
.then((res)=>{
    console.log({res})//data returned from feathersjs server
})
.catch((err)=>{
    console.log({err})
})

@daffl
Do I need to have the latest version of feathers npm on my api as well?

My current api package.json

    "@feathersjs/authentication": "^2.1.16",
    "@feathersjs/authentication-jwt": "^2.0.10",
    "@feathersjs/authentication-local": "^1.2.9",
    "@feathersjs/authentication-oauth2": "^1.3.1",
    "@feathersjs/cli": "^3.9.0",
    "@feathersjs/configuration": "^2.0.6",
    "@feathersjs/errors": "^3.3.6",
    "@feathersjs/express": "^1.3.1",
    "@feathersjs/feathers": "^3.3.1",
    "@feathersjs/socketio": "^3.2.9",
    "express": "^4.16.4",
    "feathers-authentication": "^1.3.1",
    "feathers-authentication-hooks": "^0.3.1",
    "feathers-hooks-common": "^4.20.7",
    "feathers-mongoose": "^6.3.0",

@co2nut Yes you should, look at the upgrade guide here.
The last version is 4.4.1.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arve0 picture arve0  路  4Comments

andysay picture andysay  路  3Comments

jordanbtucker picture jordanbtucker  路  4Comments

Vincz picture Vincz  路  4Comments

rstegg picture rstegg  路  3Comments