0.1.8 • Published 4 years ago

react-login-by-naver v0.1.8

Weekly downloads
23
License
MIT
Repository
github
Last release
4 years ago

원본 님이 개발하신 모듈을 수정하였습니다.

수정 내용

원본 모듈에서 firstchild 관련 undefined error가 발생하여 if(!process.browser) 구문을 if(typeof window===undefined) 로 수정하였습니다.

React-Login-By-Naver

A Naver oAuth Log-in Component for React

Install

npm install react-login-by-naver

How to use


copy your application's client ID and Callback URL.

If you have not yet registered your application, you must go to A and register your application.

testing on local environment, use not http://localhost:3000 but http://127.0.0.1:3000

import React from 'react';
import ReactDOM from 'react-dom';
import NaverLogin from 'react-login-by-naver';

ReactDOM.render(
  <NaverLogin 
    clientId="ClientIdFromNaverDeveloperCenter"
    callbackUrl="http://127.0.0.1:3000/login(callback url U set in naver developer center"
    render={(props) => <div onClick={props.onClick}>Naver Login</div>}
    onSuccess={(naverUser) => console.log(naverUser)}
    onFailure={() => console.error(result)}
  />,
  document.getElementById('root')
);

onSuccess / onFailure callback


if response is success, it will call the onSuccess with naver user object. or not, it will call the onFailure and return nothing.

You can also access the returned values via the following properties on the returned object.

Required

property namevaluedefinitionsample
emailstringNaver user email"abc@gmail.com"
idstringNaver User ID"371972918"
namestringuser name"홍길동"
profile_imagestringNaver profile image"http://img.na.."

Optional

property namevaluedefinitionsample
agestring / undefinedUser Age"20-29"
birthdaystring / undefinedUser Birthday"05-14"
genderstring / undefinedUser Gender"M"
nicknamestring / undefinedUser Nickname"tmmoond8"

Run on your machine


Prerequistes

  • Node.js v8^
  • npm

Installation


1. Clone the project

$ git clone https://github.com/moonseoklee/react-naver-login.git

2. Install packages from npm

$ cd react-naver-login 
$ npm i

3. Build packages

$ npm run build
# then, create dist directory that contains modules

4. Demo run

$ cd demo
$ npm i
$ npm run start
$ open http://127.0.0.1:3000, not http://localhost:3000