微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在ReactJS上实现Google登录?

如何解决如何在ReactJS上实现Google登录?

我已经下载了aws-amplify,并按照Amazon / google认知过程将登录页面放置在我的应用程序上。但是,我遇到了错误

“模块解析失败:意外的令牌(78:4) 您可能需要适当的加载程序来处理此文件类型。”

我尝试将配置更改为awsmobile,还尝试注释掉某些部分。

index.js

import React from "react";
import ReactDOM from "react-dom";
import { browserRouter } from "react-router-dom";
import { ThemeProvider } from "styled-components";
import { theme } from "./Components/UI";
import App from "./App";
import { Provider } from "react-redux";
import { StoreReducer } from "./reducers/reducer";
// reducers
import thunk from "redux-thunk";
import logger from "redux-logger";
import { createStore,applyMiddleware } from "redux";
import Amplify from "aws-amplify";
import config from "./aws-exports";
Amplify.configure(config)

const store = createStore(StoreReducer,applyMiddleware(thunk,logger));
console.log(store);

ReactDOM.render(
  <Provider store={store}>
  <React.StrictMode>
    <App />
  </React.StrictMode>
  </Provider>,document.getElementById('root')
);

aws-exports.js

const awsmobile = {
    "aws_project_region": "us-east-1","aws_cognito_identity_pool_id": "us-east-1:61e10159-3103-4ee0-927b-0a9daf658c4f","aws_cognito_region": "us-east-1","aws_user_pools_id": "us-east-1_TqtowtjTg","aws_user_pools_web_client_id": "6kndsi0ouqe2s8ft9h5ad1uhn","oauth": {
        "domain": "houSEOfhousesf22a0737-f22a0737-dev.auth.us-east-1.amazoncognito.com","scope": [
            "phone","email","openid","profile","aws.cognito.signin.user.admin"
        ],"redirectSignIn": "http://localhost:3000/","redirectSignOut": "http://localhost:3000/","responseType": "code"
    },"federationTarget": "COGNITO_USER_POOLS"
};


export default awsmobile;

Header.js

import React from "react";
import {Auth} from "aws-amplify";


const Header = () => {
 
  return (
         <button onClick={() => Auth.federatedSignIn({provider:"Google"})}>hfcvbn</button>
 );
};

export { Header };

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。