[Android] 기존 Google 로그인 대신 Credential Manager API를 활용한 Sign in with Google 로그인 구현하기

Jul 03, 2024
[Android] 기존 Google 로그인 대신 Credential Manager API를 활용한 Sign in with Google 로그인 구현하기

Android용 Google 로그인 에서 Android Credential Manager로 마이그레이션하는 이유

Google Sign-In for Android is deprecated and will be removed from the Google Play Services Auth SDK. (com.google.android.gms:play-services-auth) in 2025.

Android용 Google 로그인은 더 이상 사용되지 않으며 Google Play 서비스 인증 SDK에서 제거될 예정이라고 한다. 그래서 기존 구글 로그인 말고 Credential Manager로 구글 로그인을 구현해보려고 한다.

  • 몇 가지 주요 이점을 공식 문서에 확인해보면 좋을 것 같다.

  • 그리고 기존 구글 로그인과 달리 인증 및 승인이 별도의 흐름으로 제공된다고 한다.

1. Google API 콘솔 프로젝트 설정

GCP에 작업하려는 계정을 연결한다. OAuth 동의 화면에서 작업하는 앱을 등록해야한다. 그리고 사용자 인증 정보를 만들어서 안드로이드, 웹을 하나 만든다. (공식 문서)

2. 종속성 선언

종속성 선언할 때 버전 잘 맞춰주어야 한다.

dependencies {
  // ... other dependencies

  implementation "androidx.credentials:credentials:<latest version>"
  implementation "androidx.credentials:credentials-play-services-auth:<latest version>"
  implementation "com.google.android.libraries.identity.googleid:googleid:<latest version>"
}

// 다음과 같이 선언해줌

dependencies {
  // ... other dependencies
  val credential = 1.2.2 // 안정화 버전
  val googleId = 1.1.0 

  implementation "androidx.credentials:credentials:&{credential}>"
  implementation "androidx.credentials:credentials-play-services-auth:&{credential}"
  implementation "com.google.android.libraries.identity.googleid:googleid:&{googleId}"
}

3. 구글 로그인 흐름

작동되게끔 구현하는데 오래 걸렸다. 최신 버전의 공식 문서가 없어서 Credential Manager api 이용해서 구글 로그인 구현한 유튜브 영상을 참고했다.

일주일은 걸린 것 같은데, 여러 가지 이슈가 있었다. 종속성 버전이 맞지 않았는데 인지하지 못했고, 또 자격 증명 관리자 인증 및 승인 흐름을 제대로 이해하지 못해서 어떻게 구현해야 될까 고민을 많이 했다.

여러 자료를 보면서 이해하는데도 오래 걸렸다. 지금도 완벽하게 이해하지는 못한 것 같다. 천천히 다시 공부해야될 것 같다.

다음 번엔 다른 인증 방식도 구현해 볼 예정이다. (패스키 같은..)

Share article
RSSPowered by inblog