3

I'm trying to use passport-google-oauth in my react-native application. When I run the app it throws the error: requiring unknown module util . I've installed the package using npm install .. and I've also tried npm install ... --save

App/Components/Login.js

'use strict';
var React = require('react-native');
var GoogleStrategy = require('passport-google-oauth').OAuthStrategy;
...

package.json

{
 "name": "NativeApp",
 "version": "0.0.1",
 "private": true,
 "scripts": {
 "start": "node_modules/react-native/packager/packager.sh"
 },
 "dependencies": {
 "passport": ">= 0.0.0",
 "passport-google-oauth": "^0.2.0",
 "react-native": "^0.4.4"
 },
 "devDependencies": {}
}

index.ios.js

'use strict';
var React = require('react-native');
var Login = require('./App/Components/login');
var {
 AppRegistry,
 StyleSheet,
 Text,
 View,
 NavigatorIOS,
} = React;
class AppStoreIOS extends React.Component{
 render() {
 return (
 <NavigatorIOS
 titleTextColor = '#0073A0'
 // barTintColor = '#183E63'
 initialRoute={{
 component: Login,
 title: 'AppStore v2.0',
 passProps: { myProp: 'foo' },
 }}
 />
 );
 }
};
asked May 24, 2015 at 4:21

1 Answer 1

4

Don't think this going to work for you. Passport expects to be run in an node.js (express based) environment, and will at least require some work to port it to using a webview for the Oauth flow, realistically it will be a lot of work.

Have a look at https://medium.com/@jtremback/oauth-2-with-react-native-c3c7c64cbb6d for an example of how to support oauth in react-native. I haven't tried this, but it looks pretty straight forward.

answered Jun 16, 2015 at 0:19
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.