parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Any document about how to use OAuth in client side?

Open zhouhao27 opened this issue 10 years ago • 8 comments

I read the document about OAuth in parse server. But could not find the corresponding document how to use OAuth in client side. Any idea? Thanks.

zhouhao27 avatar Mar 22 '16 09:03 zhouhao27

I also ask for some doc without success. This article looks outdated https://parse.com/tutorials/adding-third-party-authentication-to-your-web-app I use the js client SDK. For all I can understand, you have to use a third party lib, like redux-auth (in my case) or hello.js and get a token, then you pass that token to parse-server (with the name of the provider), whose job is to return a Parse User.

oallouch avatar Mar 22 '16 11:03 oallouch

Looks like the client SDKs (at least javascript) support passing in your own authentication provider... Here's the simplest example from a test scenario: https://github.com/ParsePlatform/Parse-SDK-JS/blob/bb78dfb4248afcb457acbebb24f2dc583d7c14bd/src/tests/ParseUser-test.js#L576 The authenticate method would be your third party code to get the proper token, and it returns the authData object for that provider..

gfosco avatar Mar 22 '16 22:03 gfosco

Thx With this and the source of ParseUser (https://github.com/ParsePlatform/Parse-SDK-JS/blob/master/src/ParseUser.js) , we can manage something.

oallouch avatar Mar 23 '16 17:03 oallouch

@oallouch There is a function in Javascript SDK. logInWith(provider, options). But what is provider and what is the options. Any sample code? Thanks.

I tried:

Parse.User.logInWith("facebook",{})
  .then(user => {
    alert(user);
  },error => {
    alert(error.message);
  });

But got the following error:

TypeError: Cannot read property 'authenticate' of undefined

zhouhao27 avatar Mar 30 '16 04:03 zhouhao27

Nope, not for now. I postponed this part to end of my project :)

oallouch avatar Mar 30 '16 13:03 oallouch

Closing here as you opened on ParsePlatform/Parse-SDK-JS#246

flovilmart avatar Mar 31 '16 03:03 flovilmart

@flovilmart @oallouch Any one can provide client side i.e jQuery example for FB or Twitter? How can i get this Auth setup from server? An example will be greatly appreciated.

Thanks

junal avatar Feb 17 '17 22:02 junal

The Rest guide has full examples for cUrl that should be trivial to port to jQuery http://parseplatform.github.io/docs/rest/guide/

flovilmart avatar Feb 17 '17 22:02 flovilmart