[project] Lemiere #7[21.12.5]

JUNGHUN KIM·2021년 12월 5일

공부

input check 박스 관리

참고 레퍼런스 : https://been.tistory.com/14
https://developer0809.tistory.com/88

소셜로그인

참고 레퍼런스 : https://velog.io/@usreon/google-%EC%86%8C%EC%85%9C-%EB%A1%9C%EA%B7%B8%EC%9D%B8-%EC%82%BD%EC%A7%88-%EA%B3%BC%EC%A0%95

https://velog.io/@tkdfo93/%EA%B5%AC%EA%B8%80-OAuth2.0-Final-Project
https://nowonbun.tistory.com/479

https://data-jj.tistory.com/53

KPT

https://github.com/codestates/Lumiere/issues/224

  useEffect(() => {
    const url = new URL(window.location.href);
    console.log(url);
    const { hash } = url;
    console.log(hash);
    if (hash) {
      const accessToken = hash.split('=')[1].split('&')[0];
      axios
        .get(
          `https://www.googleapis.com/oauth2/v2/userinfo?access_token=${accessToken}`,
          {
            headers: {
              authorization: `token ${accessToken}`,
              accept: 'application/json',
            },
          },
        )
        .then((data) => {
          console.log(data);
        })
        .catch((e) => console.log('oAuth token expired'));
    }
 const params = {
    client_id:
      '948417619672-1e90qv63tjqpgpc5ijulelhgqmib5oj2.apps.googleusercontent.com',
    redirect_uri: 'http://localhost:3000',
    response_type: 'code',
    scope: 'https://www.googleapis.com/auth/userinfo.profile',
  };

  const oAuthURL = `https://accounts.google.com/o/oauth2/v2/auth?client_id=${params.client_id}&
response_type=${params.response_type}&
redirect_uri=${params.redirect_uri}&
scope=${params.scope}`;

  // 구글 소셜로그인 핸들러
  const googleSocailHandler = () => {
    window.location.assign(oAuthURL);
  };
profile
개발자가 되고 싶은 일문학도

0개의 댓글