jaredhanson / passport

Simple, unobtrusive authentication for Node.js.
https://www.passportjs.org?utm_source=github&utm_medium=referral&utm_campaign=passport&utm_content=about
MIT License
22.94k stars 1.24k forks source link

Can I use passort JS with React Native ? #650

Open ajai-jayakumar opened 6 years ago

ajai-jayakumar commented 6 years ago

Hi, I am currently using Angular Fullstack Generator for my web application, now I am planning to create a mobile application using React Native. Since my current application uses the passport for authentication. Is it possible to use for react native as well?

jtonneyck commented 6 years ago

I think you can. Your mobile app would probably be talking to the same back-end server, which uses passport.

suphero commented 6 years ago

passport requires ‘http’ and ‘crypto’ packages but these packages are deprecated in npm. These packages only contains a single Readme file. When you don’t install the packages RN throws ‘package not found’ exception. When you install RN throws ‘package found but index file not found’ exception. There is a reverse engineering workaround but I couldn’t apply the method successfully. I will try again in a few days, I will share the result.

http: https://www.npmjs.com/package/http

crypto: https://www.npmjs.com/package/crypto

erikrahm commented 5 years ago

Any update on this @suphero ?

dhope21 commented 2 years ago

im facing the same issue, did you figure it out @suphero

suphero commented 2 years ago

TL;DR: Maybe you can but you shouldn't use it.

It's been a long time since my answer and I obviously couldn't keep my word. I don't remember what I had in mind when I said "reverse engineering workaround".

I've rechecked the case, and it didn't work as before. The issue is: The package at "node_modules/passport/lib/middleware/authenticate.js" attempted to import the Node standard library module "http". It failed because the native React runtime does not include the Node standard library.

I checked the authenticate.js file, It doesn't look like it needs the http module much because it only uses http.STATUS_CODES. One may use passport.js with React Native by removing the http reference and updating the usage (it may be the workaround).

Coming to the original question, maybe there is a way to use but you shouldn't use passport with React Native because:

redbar0n commented 1 year ago

https://laramo.medium.com/oauth-with-facebook-and-google-for-reactnative-using-passport-js-ffe0e63f86cb