microsoftarchive / botauth

Authentication middleware for the botframework
MIT License
73 stars 78 forks source link

Feature Request: Magic code-less authentication flow #9

Open cAstraea opened 7 years ago

cAstraea commented 7 years ago

Thanks a lot for the examples was battling with this for many days and had to switch to Microsoft bot builder because it's the only one where I could find a working example of account linking. I'm trying to build a flow similar to the one used in foxsy bot https://www.messenger.com/t/foxsybot Anyone knows how to use the default Authorization from facebook dialogue where it's asking for permission instead of the magic code? Was kind of taken aback when I didn't saw that appearing :D Didn't know it was possible to make oauth request without it.

cAstraea commented 7 years ago

Hmm would probably need to add the scope inside lib/index.js ? But not sure if it works like this.

passport_callback() { const session = this.options.session; return (req, res, next) => { const providerId = req.params.providerId; return passport.authenticate(providerId, { scope: 'email', session: session })(req, res, next); }; }

So when I make the call to graph.facebook.com/v2.8/me I can request the email also and match it against an existing backend to see if the user already exists.

client.get('/v2.8/me?fields=picture,email', (err, req, res, obj) => { ..

cAstraea commented 7 years ago

YES ! it worked as I hoped I added the scope to both passport_redirect() and passport_callback() , facebook asked for my permission and returned the email ! in obj.email :) Only need to figure out how to make the process seamless without the magic code.

mattdot commented 7 years ago

when I finally finish and merge the providers branch, you'll be able to do it without the magic code