Google ID 서비스 JavaScript 라이브러리는 사용자 로그인을 위한 인증과 Google API에 사용할 액세스 토큰을 얻기 위한 승인을 모두 지원합니다. 라이브러리는 브라우저에서만 사용하도록 고안되었습니다.
인증은 사용자가 누구인지를 파악하며 일반적으로 사용자 가입 또는 로그인이라고 합니다. 승인은 데이터나 리소스에 대한 액세스 권한을 부여하거나 거부하는 프로세스입니다. 여기에는 사용자 동의를 얻고 관리하고, 범위와 공유되는 데이터 또는 리소스의 양을 제한하고, Google API에 사용할 액세스 토큰을 검색하는 작업이 포함됩니다.
이 가이드에서는 승인 및 데이터 공유 주제를 다룹니다.
사용자 승인 작동 방식에서는 사용자 승인의 개별 단계를 자세히 설명하고 사용자 대화상자의 예를 포함합니다.
인증에 도움이 필요하거나 사용자 가입 및 로그인을 구현하는 방법은 Google 계정으로 로그인을 참조하세요.
이 라이브러리는 Node.js와 같은 서버 측 JavaScript 프레임워크에서 사용하기 위한 것이 아니며, 대신 Google의 Node.js 클라이언트 라이브러리를 사용하세요.
변경된 내용
사용자를 위해 Google ID 서비스 라이브러리는 이전 JavaScript 라이브러리에 비해 다음과 같은 여러 사용성 개선사항을 제공합니다.
사용자 로그인을 위한 인증과 Google API 호출을 위한 액세스 토큰을 가져오기 위한 승인에는 이제 두 가지 별개의 사용자 플로우가 있습니다. 하나는 승인 중 로그인용이고 다른 하나는 동의용이며, 앱에서 제공하는 작업과 사용자가 누구인지 명확하게 구분하기 위한 별도의 사용자 플로우가 있습니다.
Google은 개발자를 위해 복잡성을 줄이고 보안을 강화하며 최대한 빠르고 쉽게 통합할 수 있도록 하는 데 중점을 두었습니다. 이러한 변경사항 중 일부는 다음과 같습니다.
로그인을 위한 사용자 인증과 Google API 호출을 위한 액세스 토큰을 얻는 데 사용되는 승인은 JavaScript 객체 및 메서드의 별개이며 서로 구분되어 있습니다. 이렇게 하면 인증 또는 승인을 구현하는 데 필요한 복잡성과 세부사항이 줄어듭니다.
이제 단일 JavaScript 라이브러리에서 다음 두 가지를 모두 지원합니다.
브라우저에서 사용할 액세스 토큰을 가져오는 데 사용되는 OAuth 2.0 암시적 흐름
OAuth 2.0 승인 코드 흐름(오프라인 액세스라고도 함)은 백엔드 플랫폼에 승인 코드를 안전하게 제공하여 시작되어 액세스 토큰 및 갱신 토큰으로 교환할 수 있습니다. 이전에는 여러 라이브러리를 사용하고 OAuth 2.0 엔드포인트를 직접 호출하는 방식으로만 이러한 흐름을 사용할 수 있었습니다. 단일 라이브러리를 사용하면 여러 라이브러리와 OAuth 2.0 개념을 학습하는 대신 하나의 통합 인터페이스에 집중할 수 있으므로 통합에 드는 시간과 노력을 줄일 수 있습니다.
단순성과 가독성을 위해 getter 스타일 함수를 통한 간접 참조가 삭제되었습니다.
승인 응답을 처리할 때는 사용자 대신 프로미스를 사용하여 요청을 처리할지 여부를 선택합니다.
gapi.auth2 모듈과 관련 객체 및 메서드가 더 이상 내부적으로 자동으로 로드되지 않고 더 명시적인 Google ID 서비스 라이브러리 객체 및 메서드로 대체되었습니다.
만료된 액세스 토큰의 자동 새로고침이 삭제되어 사용자 보안 및 인식이 개선되었습니다. 액세스 토큰이 만료된 후 앱은 Google API 오류 응답을 처리하고 유효한 새 액세스 토큰을 요청해야 합니다.
인증 시점과 승인 시점의 명확한 분리를 지원하기 위해 사용자가 앱과 Google 계정에 로그인하는 동시에 액세스 토큰을 발급하는 기능은 더 이상 지원되지 않습니다. 이전에는 액세스 토큰을 요청하면 사용자가 Google 계정에도 로그인되고 사용자 인증을 위해 JWT ID 토큰 사용자 인증 정보가 반환되었습니다.
사용자 보안 및 개인 정보 보호를 강화하기 위해 승인을 위해 발급되는 사용자별 사용자 인증 정보는 액세스 토큰과 이를 관리하는 데 필요한 정보만 포함하는 등 최소 권한의 원칙을 따릅니다.
[null,null,["최종 업데이트: 2023-12-01(UTC)"],[[["\u003cp\u003eGoogle Identity Services JavaScript library enables secure access to Google APIs via access tokens and supports user authentication.\u003c/p\u003e\n"],["\u003cp\u003eThe library offers separate, streamlined user flows for sign-in (authentication) and consent (authorization) for enhanced user experience and control.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers benefit from reduced complexity, improved security, and easier integration with features like a unified library for both implicit and authorization code flows.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Identity Services prioritizes user privacy and security through measures like least privilege credentials and explicit access token refresh handling.\u003c/p\u003e\n"],["\u003cp\u003eThe library is exclusively for browser-based applications and should not be used with server-side JavaScript frameworks like Node.js.\u003c/p\u003e\n"]]],[],null,["# Authorizing for Web\n\nWeb apps must obtain an access token to securely call Google APIs.\n\nThe Google Identity Services JavaScript library supports both authentication for\nuser sign-in and authorization to obtain an access token for use with Google\nAPIs. The library is intended only for use in browsers.\n\nAuthentication establishes who someone is, and is commonly referred to as user\nsign-up or sign-in. Authorization is the process of granting or rejecting access\nto data or resources. It includes obtaining and managing user consent, limiting\nthe amount of data or resources shared with scopes, and retrieving an access\ntoken for use with Google APIs.\n\nThese guides cover authorization and data sharing topics.\n\n[How user authorization works](/identity/oauth2/web/guides/how-user-authz-works) describes the individual steps of user\nauthorization in detail and includes user dialog examples.\n\nIf you are looking for help with authentication and how to implement user\nsign-up and sign-in see [Sign In With Google](/identity/gsi/web/guides/overview).\n| **Note:** The `email`, `profile`, and `openid` scopes are used for user authentication. If your app only uses these scopes [Sign In With Google](/identity/gsi/web) is recommended instead.\n\nThis library is not intended for use with server-side JavaScript frameworks such\nas Node.js, instead use Google's [Node.js](https://github.com/googleapis/google-api-nodejs-client)\nclient library.\n\nWhat's changed\n--------------\n\nFor users, the Google Identity Services library offers numerous usability\nimprovements over earlier JavaScript libraries, including:\n\n- Authentication for user sign-in, and authorization to obtain an access token to call Google APIs, now have two separate and distinct user flows; one for [sign-in](/identity/gsi/web/guides/overview#how_it_works) and another for [consent](/identity/oauth2/web/guides/how-user-authz-works#user_consent) during authorization, with separate user flows to clearly differentiate who you are, from what an app can do.\n- Improved visibility and granular control of data sharing during [user\n consent](/identity/oauth2/web/guides/how-user-authz-works#user_consent).\n- Browser based pop-up dialogs to reduce friction, and which do not require users to leave your site to:\n - obtain an access token from Google, or\n - send an authorization code to your backend platform.\n\nFor developers, our focus has been to reduce complexity, improve security, and\nmake your integration as quick and easy as possible. Some of these changes are:\n\n- User [authentication](/identity/gsi/web/reference/js-reference) for sign-in, and [authorization](/identity/oauth2/web/reference/js-reference) used to obtain an access token to call Google APIs, are two separate and distinct sets of JavaScript objects, and methods. This reduces the complexity and amount of detail required to implement authentication or authorization.\n- A single JavaScript library now supports both the:\n - OAuth 2.0 implicit flow, used to obtain an access token for use in-browser\n - OAuth 2.0 authorization code flow, also known as offline access, and initiates securely delivering an authorization code to your backend platform, where it can be exchanged for an access token and refresh token. Previously, these flows were only available by using multiple libraries and through direct calls to OAuth 2.0 endpoints. A single library decreases your integration time and effort, instead of including and learning multiple libraries and OAuth 2.0 concepts you can focus on a single, unified interface.\n- Indirection through getter style functions has been removed for simplicity and readability.\n- When handling authorization responses you choose whether or not to use a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) to fulfill requests, instead of that decision being made for you.\n- The [Google API Client Library for JavaScript](https://github.com/google/google-api-javascript-client) has been updated with these changes:\n - the `gapi.auth2` module and associated objects and methods are no longer automatically loaded for you behind the scenes, and have been replaced with more explicit Google Identity Services library objects and methods.\n - Automatic refresh of expired access tokens has been removed to improve user security and awareness. After an access token expires your app must handle Google API error responses, request, and obtain a new, valid access token.\n - To support a clear separation of authentication and authorization moments, simultaneously signing a user in to your app and to their Google Account while also issuing an access token is no longer supported. Previously, requesting an access token also signed users into their Google Account and returned a JWT ID token credential for user authentication.\n- To increase user security and privacy, per user [credentials](/identity/oauth2/web/guides/migration-to-gis#example_credentials) issued for authorization follow the principle of least privilege by including only an access token and information required to manage it."]]