programming/Web
구글 로그인 라이브러리 변경 - 2. 구글 로그인 라이브러리에서 변경되는 내용
euuuuuz:
2023. 1. 22. 17:21
정리할 내용
- Google Identity 간단 개념 (+ oauth) 👉 링크
- 구글 라이브러리에서 변경되는 내용
- authorization 에서 flow 선택
- 라이브러리를 사용하지 않고 googl oauth api로 direct 요청하기
- 토이플젝을 통해서 code → token 얻어내는 과정 및 유의사항
- 기존 로그인 플로우 & 변경되는 로그인 플로우 설명
변경되는 내용
- library의 deprecate
- 2023.01.04 Google Sign-in Javascript 라이브러리가 (gapi.auth2 모듈) deprecated 되었다. 2023년 3월 31일부터 다운로드가 안된다. Google Identity Services for Web을 사용해라.
- 출처 : Discontinuing authorization support for the Google Sign-In JavaScript Platform Library
- AS-IS
- Google Sign-In JavaScript platform library (deprecated)
- Google API Client Library for JavaScript (deprecated)
- gapi client 를 포함하여 Google API 서비스를 이용할 수 있게 해주는 라이브러리
- authorization 요청시 access_token 과 id_token을 함께 줬었다 (링크)
- TO-BE
- authorization 과 authentication 을 분리
- authentication
- id_token
- 구글 Sign In - 단순 로그인이 필요한 경우 사용
- google 에서 제공하는 로그인 버튼, 자동로그인, One-Tap 키트를 제공 → 어떤 사이트든 유저가 동일한 UX를 경험할 수 있다
- credentialResponse → JWT (id_token)
{ "clientId": "538344653255-758c5h5is6to.apps.googleusercontent.com", "credential": "eyJhbGciOizA1Y2wiZW1haWIjoiNTM4MzQ0_UO6OCRQ", "select_by": "user" } - authorization
- access_token
- 구글 서비스 API 가 필요한 경우 사용 (ex) 구글 드라이브, 구글 메일 등)
- 또는 access_token & refresh_token 을 사용한 로그인 방식을 사용하고 싶은 경우
{ "access_token": "ya29.A0ARrdaM_LWSO-hEr_FAVqf92sZZHphr0g", "token_type": "Bearer", "expires_in": 3599, "scope": "<https://www.googleapis.com/auth/calendar.readonly>" }
- authentication
- authorization 과 authentication 을 분리
- library 정리
- implicit flow? authorization_code flow? 일단은 몰라도 되고, 그저 하나의 라이브러리로 통합되었다는 것만 확인하면 된다
| library (deprecated) | New library | Note |
| apis.google.com/js/platform.js | accounts.google.com/gsi/client | Add new library for authentication(id_token) |
| apis.google.com/js/api.js | accounts.google.com/gsi/client | Add new library for authorization(access_token) and follow the implicit flow. |
| apis.google.com/js/client.js | accounts.google.com/gsi/client | Add new library for authorization(access_token) and the authorization code flow. |