Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

토큰획득 프로세스 #18

Open
ParkYunHo opened this issue Feb 28, 2023 · 1 comment
Open

토큰획득 프로세스 #18

ParkYunHo opened this issue Feb 28, 2023 · 1 comment

Comments

@ParkYunHo
Copy link
Contributor

ParkYunHo commented Feb 28, 2023

What is the Issues?

소셜로그인별 토큰획득 프로세스

Details

카카오 로그인

  • access_token, refresh_token은 native SDK를 통해 native 자체적으로 획득한다.
  • refresh_token은 별도 인코딩과정없이 native local-storage를 통해 관리한다.
  • access_token은 서버의 "인코딩API"를 호출하여 인코딩된 access_token을 획득하고 이를 native local-storage를 통해 관리한다.
/* 인코딩API */
// request
curl -v -G -X GET "http://localhost:8080/login/encode" \
  -d  "state=kakao" \
  -d  "token={access_token}"

// response
{
 "provider": "kakao",
 "accessToken": {encoded_access_token}
}

애플로그인

  • native 내에서 로그인과정을 거쳐 사용자의 "identity_token"을 획득한다.
  • 획득한 identity_token을 parameter로 서버의 "토큰획득 API"를 호출하여 access_token을 획득한다.
  • 애플로그인의 경우, 별도 refresh_token은 존재하지 않는다.
  • 획득한 access_token을 parameter로 서버의 "인코딩API"를 호출하여 인코딩된 access_token을 획득하고 이를 native local-storage를 통해 관리한다.
/* 토큰획득 API */
// request
curl -v -G -X GET "http://localhost:8080/login/token" \
  -d "state=apple" \
  -d "token={identity_token}

// response
{
  "accessToken": {access_token},
  "refreshToken": ""
}

/* 인코딩API */
// request
curl -v -G -X GET "http://localhost:8080/login/encode" \
  -d  "state=apple" \
  -d  "token={access_token}"

// response
{
 "provider": "apple",
 "accessToken": {encoded_access_token}
}

인증방법

  • "토큰획득API, 인코딩API"를 제외한 모든 서버의 API 호출시 "access_token"을 Header에 포함하여 request 해야한다.
  • 예제
curl -v -X GET "http://localhost:8080/users" \
  -H "Authorization: Bearer {encoded_access_token}"

access_token 만료시

  • HttpStatus 401 에러발생시 "미유효한 access_token"을 의미하며 아래 프로세스를 진행시킨다.

카카오 로그인

  • native local-storage에 저장한 "refresh_token"으로 native SDK를 호출하여 access_token을 재발급받는다.
  • 재발급받은 access_token을 parameter로 서버의 "인코딩API"를 호출하여 인코딩된 access_token을 획득하고 이를 native local-storage를 통해 관리한다.

애플 로그인

  • 애플로그인은 별도 refresh_token이 없으므로 "로그아웃"처리와 동일하게 처리한다.
  • 사용자의 재로그인이 필요함을 사용자에게 알리고 재로그인 화면으로 이동시킨다.
@ParkYunHo
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant