codestates / codestates/laggard-client
네이버 소셜 로그인
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
### ISSUE
- Type: `feature`
- Detail: 네이버 소셜 로그인
### TODO
일단 저는 간단하게 만들어보려고 리액트에서 App.js에서 구현했습니다.
index.html 바디태그 제일 밑쪽에
`` 코드 추가
```js
import logo from "./logo.svg";
import "./App.css";
import React, { useEffect } from "react";
import axios from "axios";
function App() {
const { naver } = window;
// const location = useLocation();
console.log("naver : ", naver);
const initializeNaverLogin = () => {
const naverLogin = new naver.LoginWithNaverId({
clientId: "네이버 개발자센터 애플리케이션 클라이언트 아이디",
callbackUrl: "http://localhost:3000",
isPopup: false,
loginButton: { color: "white", type: 1, height: "47" },
});
naverLogin.init();
naverLogin.getLoginStatus(function (status) {
if (status) {
console.log("status : ", status);
console.log(naverLogin.user);
let email = naverLogin.user.getEmail();
let gender = naverLogin.user.getGender();
let name = naverLogin.user.getName();
let birthYear = naverLogin.user.getBirthyear();
// console.log("birthYear : ", naverLogin.user.getBirthyear);
// console.log("aa : ", naverLogin.user.email);
if (email === undefined || email === null) {
alert("이메일 항목을 체크해주세요");
naverLogin.reprompt();
return;
}
if (birthYear === undefined || birthYear === null) {
alert("출생년도항목을 체크해주세요");
naverLogin.reprompt();
return;
}
}
});
};
const getNaverToken = () => {
const url = new URL(window.location.href);
console.log("url : ", url);
if (url.hash) {
const token = url.hash.split("=")[1].split("&")[0];
console.log("token : ", token);
// socialLoginRequest(token);
}
};
// const socialLoginRequest = (token) => {
// axios
// .get("http://localhost:5000/naverLogin", {
// headers: { authorization: token },
// })
// .then((result) => {
// console.log("success : ", result);
// })
// .catch((err) => {
// console.log("err : ", err);
// });
// };
useEffect(() => {
initializeNaverLogin();
getNaverToken();
});
return (
);
}
export default App;
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.