Using passport-google-oauth with react
I am trying to use passport-google-oauth in my react based application. When I run the app, it gives an error: requiring unknown module util
. I installed the package with npm install ..
and I also triednpm 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' },
}}
/>
);
}
};
source to share
Don't assume this will work for you. Passport expects it to be run in a node.js environment (expression based) and will at least require some work to port it to use a web view for an Oauth flow, realistically there will be a lot of work.
Take a look at https://medium.com/@jtremback/oauth-2-with-react-native-c3c7c64cbb6d for an example of how to support oauth in native-native. I haven't tried this, but it looks pretty straight forward.
source to share