【问题标题】:Using passport-google-oauth with react-native将护照谷歌oauth与react-native一起使用
【发布时间】:2015-08-05 20:31:33
【问题描述】:

我正在尝试在我的 react-native 应用程序中使用 passport-google-oauth。当我运行该应用程序时,它会引发错误:requiring unknown module util。我已经使用npm install .. 安装了该软件包,并且我也尝试过npm install ... --save

应用/组件/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' },
        }}
      />
    );
  }
};

【问题讨论】:

    标签: node.js oauth npm reactjs react-native


    【解决方案1】:

    不要认为这对你有用。 Passport 期望在 node.js(基于 express)环境中运行,并且至少需要一些工作才能将其移植到使用 webview 进行 Oauth 流程,实际上这将是很多工作。

    查看https://medium.com/@jtremback/oauth-2-with-react-native-c3c7c64cbb6d 以了解如何在 react-native 中支持 oauth 的示例。我还没有尝试过,但它看起来很简单。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-01-29
      • 2014-10-20
      • 2014-08-12
      • 1970-01-01
      • 2019-11-15
      • 2019-06-06
      • 2020-11-27
      相关资源
      最近更新 更多