개요

계정 연결을 사용하면 Google 계정 소유자가 빠르고 원활하고 안전하게 서비스에 연결할 수 있습니다. Google 계정 연결을 구현하여 플랫폼의 사용자 데이터를 Google 앱 및 서비스와 공유할 수도 있습니다.

안전한 OAuth 2.0 프로토콜을 사용하면 사용자의 Google 계정을 플랫폼의 해당 계정과 안전하게 연결할 수 있으므로 Google 애플리케이션과 기기가 서비스에 액세스할 수 있습니다.

사용자는 계정을 연결하거나 연결 해제할 수 있으며, Google 계정 연결을 사용하여 플랫폼에서 새 계정을 만들 수도 있습니다.

사용 사례

Google 계정 연결을 구현하는 이유는 다음과 같습니다.

  • 플랫폼의 사용자 데이터를 Google 앱 및 서비스와 공유합니다.

  • Google TV를 사용하여 동영상 및 영화 콘텐츠를 재생합니다.

  • Google Home 앱과 Google 어시스턴트, "Hey Google 조명 켜 줘"를 사용하여 연결된 Google 스마트 홈 기기를 관리하고 제어합니다.

  • 대화형 작업, "Hey Google, 스타벅스에서 평소 주문해 줘"를 통해 사용자 맞춤 Google 어시스턴트 환경과 기능을 만드세요.

  • 사용자가 Google 계정을 리워드 파트너 계정에 연결한 후 YouTube에서 요건을 충족하는 실시간 스트림을 시청하여 리워드를 받을 수 있도록 합니다.

  • 가입하는 동안 Google 계정 프로필에서 동의를 공유한 데이터로 새 계정을 미리 입력합니다.

지원되는 기능

Google 계정 연결을 통해 다음 기능을 사용할 수 있습니다.

  • OAuth 연결 암시적 흐름을 사용하여 데이터를 빠르고 쉽게 공유합니다.

  • OAuth 연결 승인 코드 흐름을 사용하여 보안을 강화합니다.

  • 기존 사용자를 로그인하거나 Google 인증 신규 사용자를 플랫폼에 등록하고, 동의를 얻고, 간소화된 연결로 데이터를 안전하게 공유합니다.

  • 앱 전환을 통해 불편함을 줄이세요. 신뢰할 수 있는 Google 앱에서 탭 한 번이면 인증된 Android 또는 iOS 앱이 안전하게 열리고, 탭 한 번으로 사용자 동의를 부여하여 계정이 연결됩니다.

  • 필요한 데이터만 공유하도록 맞춤 범위를 정의하여 사용자 개인 정보 보호를 개선하고, 데이터 사용 방식을 명확하게 정의하여 사용자 신뢰를 높입니다.

  • 계정을 연결 해제하면 플랫폼에서 호스팅되는 데이터 및 서비스에 대한 액세스 권한이 취소될 수 있습니다. 선택사항인 토큰 취소 엔드포인트를 구현하면 Google에서 시작한 이벤트와 동기화된 상태를 유지할 수 있으며, 계정 간 보안(RISC)을 사용하면 플랫폼에서 발생하는 연결 해제 이벤트를 Google에 알릴 수 있습니다.

계정 연결 흐름

Google 계정 연결 흐름은 세 가지가 있으며 모두 OAuth를 기반으로 하며 OAuth 2.0 규정 준수 승인 및 토큰 교환 엔드포인트를 관리하거나 제어해야 합니다.

연결 프로세스 중에 계정 연결 및 데이터 공유에 대한 계정 소유자의 동의를 얻은 후 개별 Google 계정에 대한 액세스 토큰을 Google에 발급합니다.

OAuth 연결 ('웹 OAuth')

이는 연결을 위해 사용자를 웹사이트로 보내는 기본 OAuth 흐름입니다. 사용자가 계정에 로그인하기 위해 웹사이트로 리디렉션됩니다. 로그인하면 사용자는 서비스에서 Google과 데이터를 공유하는 데 동의합니다. 그러면 사용자의 Google 계정과 서비스가 연결됩니다.

OAuth 연결은 승인 코드 및 암시적 OAuth 흐름을 지원합니다. 서비스는 암시적 흐름에 대해 OAuth 2.0 규정 준수 승인 엔드포인트를 호스팅해야 하며 승인 코드 흐름을 사용할 때 승인 및 토큰 교환 엔드포인트를 모두 노출해야 합니다.

그림 1. 웹 OAuth를 사용하여 사용자 휴대전화에서 계정 연결

OAuth 기반 앱 플립 연결 ('앱 플립')

연결을 위해 사용자를 으로 보내는 OAuth 흐름

OAuth 기반 앱 플립 연결은 인증된 Android 또는 iOS 모바일 앱과 Google 플랫폼 간에 이동할 때 사용자를 안내하여 제안된 데이터 액세스 변경사항을 검토하고 개발자 플랫폼의 계정을 Google 계정과 연결하는 데 동의할 수 있도록 합니다. 앱 플립을 사용 설정하려면 승인 코드 흐름을 사용하여 서비스에서 OAuth 연결 또는 OAuth 기반 Google 로그인 연결을 지원해야 합니다.

앱 플립은 AndroidiOS에서 모두 지원됩니다.

작동 방식:

Google 앱은 다음과 같이 사용자의 기기에 앱이 설치되어 있는지 확인합니다.

  • 앱이 발견되면 사용자는 앱으로 '돌아갔습니다'. 앱이 계정을 Google과 연결하기 위해 사용자로부터 동의를 얻은 다음 Google 표시 경로로 '돌아갑니다'.
  • 앱 전환 프로세스 중에 앱을 찾을 수 없거나 오류가 발생하면 사용자는 간소화된 또는 웹 OAuth 흐름으로 리디렉션됩니다.

그림 2. 앱 플립을 통해 사용자 휴대전화에서 계정 연결

OAuth 기반의 간소화된 연결 ('간소화됨')

OAuth 기반 Google 로그인의 간소화된 연결은 OAuth 연결 외에 Google 로그인을 추가하여 사용자가 Google 표시 경로를 나가지 않고도 연결 프로세스를 완료할 수 있도록 하여 마찰과 중단을 줄여줍니다. OAuth 기반 간소화된 연결은 Google 로그인을 OAuth 연결과 결합하여 원활한 로그인, 계정 생성, 계정 연결을 통해 최상의 사용자 환경을 제공합니다. 서비스는 OAuth 2.0 규정 준수 승인 및 토큰 교환 엔드포인트를 지원해야 합니다. 또한 토큰 교환 엔드포인트는 JSON 웹 토큰(JWT) 어설션을 지원하고 check, create, get 인텐트를 구현해야 합니다.

작동 방식:

Google은 사용자 계정을 어설션하고 이 정보를 개발자에게 전달합니다.

  • 사용자의 계정이 데이터베이스에 있는 경우 사용자는 Google 계정을 서비스의 해당 계정과 성공적으로 연결합니다.
  • 데이터베이스에 사용자의 계정이 없는 경우 사용자는 Google에서 제공하는 이메일, 이름, 프로필 사진 등의 어설션 정보를 사용하여 새 서드 파티 계정을 만들거나 로그인하여 다른 이메일로 연결할 수 있습니다 (웹 OAuth를 통해 서비스에 로그인해야 함).

그림 3. 간소화된 연결을 통해 사용자 휴대전화에서 계정 연결

어떤 흐름을 사용해야 하나요?

사용자에게 최상의 연결 환경을 제공하려면 모든 흐름을 구현하는 것이 좋습니다. 간소화된 흐름 및 앱 전환 흐름을 사용하면 사용자가 몇 단계만으로 연결 절차를 완료할 수 있으므로 연결 마찰을 줄일 수 있습니다. 웹 OAuth 연결은 작업량이 가장 적으므로 시작한 후 다른 연결 흐름을 추가할 수 있습니다.

토큰 작업

Google 계정 연결은 OAuth 2.0 업계 표준을 기반으로 합니다.

계정 연결 및 데이터 공유에 대한 계정 소유자의 동의를 얻은 후 개별 Google 계정의 액세스 토큰을 Google에 발급합니다.

Token types

OAuth 2.0 uses strings called tokens to communicate between the user agent, the client application, and the OAuth 2.0 server.

Three types of OAuth 2.0 tokens can be used during account linking:

  • Authorization code. A short-lived token that can be exchanged for an access and a refresh token. For security purposes, Google calls your authorization endpoint to obtain a single use or very short-lived code.

  • Access token. A token that grants the bearer access to a resource. To limit exposure that could result from the loss of this token, it has a limited lifetime, usually expiring after an hour or so.

  • Refresh token. A long-lived token that can be exchanged for a new access token when an access token expires. When your service integrates with Google, this token is exclusively stored and used by Google. Google calls your token exchange endpoint to exchange refresh tokens for access tokens, which are in turn used to access user data.

Token handling

Race conditions in clustered environments and client-server exchanges can result in complex timing and error handling scenarios when working with tokens. For example:

  • You receive a request for a new access token, and you issue a new access token. Concurrently, you receive a request for access to your service's resource using the previous, unexpired access token.
  • Your refresh token reply is yet to be received (or is never received) by Google. Meanwhile, the previously valid refresh token is used in a request from Google.

Requests and replies can arrive in any order, or not at all due to asynchronous services running in a cluster, network behavior, or other means.

Immediate and fully consistent shared state both within, and between, your and Google's token handling systems cannot be guaranteed. Multiple valid, unexpired tokens can coexist within or across systems short period of time. To minimize negative user impact we recommend you do the following:

  • Accept unexpired access tokens, even after a newer token is issued.
  • Use alternatives to Refresh Token Rotation.
  • Support multiple, concurrently valid access and refresh tokens. For security, you should limit the number of tokens and token lifetime.
Maintenance and outage handling

During maintenance or unplanned outages Google might be unable to call your authorization or token exchange endpoints to obtain access and refresh tokens.

Your endpoints should respond with a 503 error code and empty body. In this case, Google retries failed token exchange requests for a limited time. Provided that Google is later able to obtain refresh and access tokens, failed requests are not visible to users.

Failing requests for an access token result in a visible error, if initiated by a user. Users will be required to retry linking failures if the implicit OAuth 2.0 flow is used.

Recommendations

There are many solutions to minimize maintenance impact. Some options to consider:

  • Maintain your existing service and route a limited number of requests to your newly updated service. Migrate all requests only after confirming expected functionality.

  • Reduce the number of token requests during the maintenance period:

    • Limit maintenance periods to less than the access token lifetime.

    • Temporarily increase the access token lifetime:

      1. Increase token lifetime to greater than maintenance period.
      2. Wait twice the duration of your access token lifetime, enabling users to exchange short lived tokens for longer duration tokens.
      3. Enter maintenance.
      4. Respond to token requests with a 503 error code and empty body.
      5. Exit maintenance.
      6. Decrease token lifetime back to normal.

Google에 등록

계정 연결을 사용 설정하려면 OAuth 2.0 설정에 대한 세부정보와 사용자 인증 정보를 공유해야 합니다. 자세한 내용은 등록을 참고하세요.