1.0.7 • Published 2 years ago

dankook-student-council-login v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

dankook-student-council-login

단국대학교 총학생회 로그인 컴포넌트

Getting Started

Installation

  • NPM
npm install dankook-student-council-login
  • Yarn
yarn add dankook-student-council-login

Environment

  • React

Usage

  • React
import DankookStudentCouncilLogin from "dankook-student-council-login";

<DankookStudentCouncilLogin
  clientId={clientId}
  redirectUri={redirectUri}
  onSuccess={onSuccess}
/>;
  • Next.js ssr 환경에서 동작하지 않으므로 동적 import가 필요합니다.
const DankookStudentCouncilLogin = dynamic(
  () => import("dankook-student-council-login"),
  {
    ssr: false,
  }
);

<DankookStudentCouncilLogin
    ...
/>

Property

nametypedescriptionnote
clientIdstringOAuth 사용 허가를 위한 클라이언트 ID개발자에 문의하여 발급
redirectUristring로그인 성공 시 리다이렉트 될 URI해당 컴포넌트가 작성된 URI
style?CSSProperties로그인 버튼 스타일을 덮어쓰는 오브젝트
onSuccessFunction리다이렉트 이후 authCode를 파라미터로 가져오는 메서드
onError?Function로그인 실패 시 에러 핸들링을 구현하는 메서드

토큰 발급 플로우

onSuccess

로그인 성공 시 authCode와 codeVerifier가 onSuccess의 인자로 반환되며, 이를 사용해서 Access Token과 Refresh Token을 발급받습니다.

interface AuthorizeResponse {
  authCode: string;
  codeVerifier: string;
}

const onSuccess = (res: AuthorizeResponse) => {
  getToken(res);
};

토큰 발급 API

POST https://danvery.com/api/oauth/token

  • Parameters

    nametypenote
    grantTypestringauthorization code 사용
    clientIdstring개발자에 문의하여 발급
    clientSecretstring개발자에 문의하여 발급
    redirectUristring
    codestringonSuccess의 인자로 받은 authCode
    codeVerifierstringonSuccess의 인자로 받은 codeVerifier
  • Responses

    coderesponse keyresponse type
    200accessTokenstring
    refreshTokenstring
    tokenTypestring
    scopestring
1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago