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

no callback from app.authenticate #1705

Closed
co2nut opened this issue Nov 27, 2019 · 8 comments
Closed

no callback from app.authenticate #1705

co2nut opened this issue Nov 27, 2019 · 8 comments

Comments

@co2nut
Copy link

co2nut commented Nov 27, 2019

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?

@co2nut
Copy link
Author

co2nut commented Nov 28, 2019

tried with this setup:
feathersjs-ecosystem/feathers-localstorage#16
but still not working

@co2nut
Copy link
Author

co2nut commented Nov 28, 2019

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;

@co2nut co2nut closed this as completed Nov 28, 2019
@co2nut co2nut reopened this Nov 28, 2019
@co2nut
Copy link
Author

co2nut commented Nov 28, 2019

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

Still looking for solution

@Pirsanth
Copy link

I am facing the same issue

@daffl
Copy link
Member

daffl commented Nov 28, 2019

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

@co2nut
Copy link
Author

co2nut commented Nov 28, 2019

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})
})

@co2nut
Copy link
Author

co2nut commented Nov 28, 2019

@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",

@J3m5
Copy link

J3m5 commented Nov 29, 2019

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

@daffl daffl closed this as completed Dec 4, 2019
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

No branches or pull requests

4 participants