gpt4 book ai didi

node.js - 将 passport-google-oauth 与 react-native 结合使用

转载 作者:搜寻专家 更新时间:2023-10-31 23:47:54 26 4
gpt4 key购买 nike

我正在尝试使用 passport-google-oauth在我的 native react 应用程序中。当我运行该应用程序时,它会抛出错误: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' },
}}
/>
);
}
};

最佳答案

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

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

关于node.js - 将 passport-google-oauth 与 react-native 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30420056/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com