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

oauth with Digits #2280

Closed
ranhsd opened this issue Jul 14, 2016 · 7 comments
Closed

oauth with Digits #2280

ranhsd opened this issue Jul 14, 2016 · 7 comments

Comments

@ranhsd
Copy link
Contributor

ranhsd commented Jul 14, 2016

Hi ,
twitter Digits provide password-free login for mobile apps. One of the coolest feature of parse-server is to allow users to login with 3rd party providers like: twitter, facebook, instegram etc.
I just wanted to inform you that it is possible to use twitter oauth provider also with Digits.
In order to test it please do the following:

  1. Configure twitter provider but use the consumer key and consumer secret of Digits taken from your fabric dashboard - https://fabric.io
  2. Create a simple iOS client with the following code:
    [[Digits sharedInstance] authenticateWithViewController:nil configuration:configuration completion:^(DGTSession *session, NSError *error) {
        if (error) {
            return;
        }

        [PFUser registerAuthenticationDelegate:self forAuthType:@"twitter"];


        [[PFUser logInWithAuthTypeInBackground:@"twitter" authData:@{@"auth_token" : session.authToken,@"auth_token_secret" : session.authTokenSecret,@"id" : session.userID}] continueWithBlock:^id _Nullable(BFTask<__kindof PFUser *> * _Nonnull task) {

            if (task.error){
                NSLog(@"error occured %@",task.error);
            }

            return nil;
        }];

The code above do the following:

  • authenticate the user (only by his phone number... no password is required)
  • Register authentication delegate for the parse user
  • Log in with twitter and send the token, secret token and id of the Digit user.

The digit session also return the user phone number so you can also store the user phone number in the DB.

This way you can allow your users to login with their phone numbers only (password-free)

BTW, if you have multiple apps and you want to provide one login so user will not need to fill in his/her profile each time they signed up you can use AWS Cognito for that. I tried it and it works great with Parse Server.
More details about it can be found here: http://docs.aws.amazon.com/cognito/latest/developerguide/twitter.html

@flovilmart
Copy link
Contributor

We could definitely add digit as an auth provider

@hasso92
Copy link

hasso92 commented Jul 14, 2016

I have cloud Code functions that handle that, I can provide it once I'm
home, so far it's working with no issues at all.

Am Donnerstag, 14. Juli 2016 schrieb Florent Vilmart :

We could definitely add digit as an auth provider


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#2280 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AQWahqSNAZR-xcx6bFemoQuOfhryOciYks5qVjFGgaJpZM4JMUjI
.

@ranhsd
Copy link
Contributor Author

ranhsd commented Jul 14, 2016

Hi @hasso92,
Until now I use cloud for authenticate the users but I think it's better to use provider in order to go with the "standard way"

@flovilmart - we can use the same code line of the Twitter provider but change only the provider name to digits. In this way developers will be able to provide 2 authentication login , with digits or with Twitter... What do you think ?

@flovilmart
Copy link
Contributor

flovilmart commented Jul 14, 2016

@ranhsd I was thinking about that actually:

https://github.com/ParsePlatform/parse-server/blob/master/src/authDataManager/index.js#L9

here add let digits = require('./twitter'); // digits tokens are validated by twitter

@ranhsd
Copy link
Contributor Author

ranhsd commented Jul 14, 2016

@flovilmart - great solution .. I will test it and do a pull request (unless you already did it ;) )

@flovilmart
Copy link
Contributor

go for it, test it :)

@flovilmart
Copy link
Contributor

Closing as it's been merged

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

3 participants