Social Login (Linkedin): Do we have to manually login on every refresh of the app?


#1

Hi,

I am using Skygear Javascript SDK.

I have logged using Skygear social login and got a user object same as (skygear.auth.currentUser). However, when I refresh the page, the same object (skygear.auth.currentUser) is empty(null).

Do we have to log in manually on every refresh? or Is there any other way to check login state using access token? or any other possibility?

Could anyone please help me on this?


#2

Hi it sounds like the object have problem persist locally. Any error message from console?

What about when you call whoami() like below, did it works? It can confirm either the user was logged out, or just the current_user object have trouble persist.

skygear.auth.whoami().then((user) => {
    console.log(`Oh. I am ${user.username}.`);
}, (err) => {
    // Error handling...
})

#3

@bencheng I’m getting below error when I use this.

{"error":{"name":"NotAuthenticated","code":101,"message":"Authentication is required for this action, please login."}}


#4

It seems for some reason your user can’t keep the login session when you refresh the page.

Are you on Safari Private Window or Incognito Mode of Chrome or anything like that?

If not, can you check the following, and I suppose you’re using an open source version of Skygear?

  1. Did it have problems with normal user login? Or it only happens with Linkedin only? (Check normal user by maybe simply open a Javascript console loaded with Skygear Container, and use signupWithUsername, etc)
    1. If it is with Linkedin only, can you share us the code of your Linkedin AuthProvider so our developer can help check if some problems exists?
    2. If it happens with normal user too, I suspect it is related with deployment. Can you share more with us how you deploy it?

#5

Thanks, @bencheng. I will try all the possibilities once.