Files
llm-wiki/raw/official-docs/google-oauth2-web-server-flow-official.md

83 lines
9.9 KiB
Markdown

---
title: official-doc / Google Identity — Using OAuth 2.0 for Web Server Applications
source_type: official-doc
url: https://developers.google.com/identity/protocols/oauth2/web-server
archive_url:
related_branches: [feature-keycloak-google-redirect-uri-policy]
related_projects: [keycloak-patterns]
tags: [official-doc, keycloak-patterns, auth, oauth2, google-aip]
created: 2026-07-16
---
# official-doc / Google Identity — Using OAuth 2.0 for Web Server Applications
> Layer: `raw/` — 외부 자료(공식 문서)의 원문 발췌·출처 기록. 검증된 요약은 `/ingest` 후 `wiki/concepts/`에 별도 작성. 원본은 raw에 영구 보관.
## Parent / 활용 branch
| Branch | 이 자료가 정당화하는 결정 |
|---|---|
| [[raw/branch-notes/feature-keycloak-google-redirect-uri-policy]] | D6 — Google OAuth client 의 confidential/server-to-server (`Web application`) flow 채택 근거. Keycloak 이 server-side 로 `/token` 을 호출하는 flow 라는 점, "Web application" application type 을 선택하라는 명시적 지침, 그리고 Authorized redirect URIs 요구사항이 이 문서에 근거함. 이 문서는 "JavaScript origins" 를 다루지 않으므로 — JS origins 를 비워두는 결정은 이 문서만으로는 뒷받침되지 않음(별도 근거 필요, `UNSUPPORTED_DECISION` 유지). |
## 출처 / Source
- 원본 URL: https://developers.google.com/identity/protocols/oauth2/web-server
- 아카이브 URL: (미제공)
- 저자 / 조직: Google (Google Identity Platform — Google Identity 공식 문서)
- 발행일: (문서에 명시적 발행일 없음 — Google Identity 공식 레퍼런스, 상시 갱신)
- 마지막 확인일: 2026-07-16
## 왜 저장했는지 / Why archived
Keycloak 이 Google 을 OIDC/OAuth2 IdP 로 브로커링할 때, Google 이 정의하는 "web server application" flow (confidential client, server-side token exchange) 가 정확히 Keycloak 의 동작 방식과 일치하는지 확인하기 위해 저장. `feature-keycloak-google-redirect-uri-policy` D6 (Application type = Web application, JS origins 비움) 의 근거 공백을 메우려는 목적.
## 핵심 인용 / Key quotes (verbatim, 5문장)
> [§Overview] "This OAuth 2.0 flow is specifically for user authorization. It is designed for applications that can store confidential information and maintain state." (line 33 in fetched text)
> [§Create authorization credentials — Set a redirect URI] "Select the Web application application type." (line 39 in fetched text)
> [§Set a redirect URI] "Applications that use languages and frameworks like PHP, Java, Python, Ruby, and .NET must specify authorized redirect URIs." (line 46 in fetched text)
> [§Step 5: Exchange authorization code for refresh and access tokens] "POST /token HTTP/1.1" / "Host: oauth2.googleapis.com" / "client_id=your_client_id&" / "grant_type=authorization_code" (lines 49-56 in fetched text — literal code sample of the token-exchange HTTP request)
> [§Step 5 parameter table — `client_secret`] "The client secret obtained from the Cloud Console [Clients page]." — parameter listed as **Optional** in the general parameter table, not marked required in the literal example code block shown above (line 71/74 in fetched text)
## Claims Extracted / 추출된 주장
| Claim ID | Claim (이 자료가 직접 말하는 것) | Evidence quote | Strength | Applies to | Does not prove |
|---|---|---|---|---|---|
| GOOGLE-WEBSERVER-C1 | 이 문서가 설명하는 OAuth 2.0 web-server flow 는 confidential information 을 저장하고 state 를 유지할 수 있는 애플리케이션을 위해 설계됨 | "This OAuth 2.0 flow is specifically for user authorization. It is designed for applications that can store confidential information and maintain state." | `official-vendor-doc` | server-side/confidential client 아키텍처(Keycloak 같은 IdP broker 포함)가 이 flow 범주에 해당함을 뒷받침 | "confidential" 의 정확한 기술적 경계(예: client_secret 저장 위치·rotation 정책)는 이 문장만으로 정의되지 않음 |
| GOOGLE-WEBSERVER-C2 | OAuth credentials 생성 시 "Web application" application type 을 선택하도록 명시적으로 지시 | "Select the Web application application type." | `official-vendor-doc` | Keycloak Google IdP 등록 시 Google Cloud Console 에서 선택할 Application type 값 = `Web application` | "Web application" type 과 다른 type(예: Desktop, TVs/Limited Input) 간의 세부 기능 차이는 이 한 문장으로 증명되지 않음 |
| GOOGLE-WEBSERVER-C3 | PHP/Java/Python/Ruby/.NET 같은 언어·프레임워크를 쓰는 애플리케이션은 authorized redirect URIs 를 반드시 지정해야 함 | "Applications that use languages and frameworks like PHP, Java, Python, Ruby, and .NET must specify authorized redirect URIs." | `official-vendor-doc` | server-side 애플리케이션(Keycloak 포함, JVM 기반)이 Authorized redirect URIs 를 등록해야 하는 근거 | 이 문장은 "JavaScript origins" 요구사항을 언급하지 않음 — JS origins 를 비워도 되는지 여부에 대해서는 침묵(증명도 반증도 아님) |
| GOOGLE-WEBSERVER-C4 | 토큰 교환은 `https://oauth2.googleapis.com/token` 에 대한 서버 측 HTTP POST 이며, 예시 코드에는 `code`, `client_id`, `redirect_uri`, `grant_type=authorization_code` 파라미터가 literal 하게 표시됨 | "POST /token HTTP/1.1" / "Host: oauth2.googleapis.com" / "client_id=your_client_id&" / "grant_type=authorization_code" | `official-vendor-doc` | 토큰 엔드포인트 URL 과 HTTP method, 그리고 `client_id`/`grant_type`/`redirect_uri`/`code` 파라미터가 실제 예시에 등장함을 증명 | 이 예시 코드 블록 자체에는 `client_secret` 이 literal 하게 표시되지 않음 — client_secret 이 이 특정 요청에 "항상 필수"라는 것은 이 코드 블록만으로는 증명되지 않음(별도 파라미터 표 참조, 아래 C5) |
| GOOGLE-WEBSERVER-C5 | `client_secret` 파라미터는 Cloud Console 에서 발급받는 client secret 이며, 문서의 일반 파라미터 표에서는 **Optional** 로 표기됨 | "The client secret obtained from the Cloud Console [Clients page]." (파라미터 표, Optional 로 라벨링) | `official-vendor-doc` | `client_secret` 이 무엇인지(출처: Cloud Console) 를 증명. confidential client 인 web-server flow 맥락에서는 사실상 필요하지만, 문서의 표 라벨 자체는 "Optional" | 이 표가 "Optional" 이라고 표기한 이유(다른 flow 유형과 공유되는 범용 파라미터 표이기 때문인지)는 이 인용만으로 확정 불가 — web-server flow 한정 "client_secret 필수" 단정은 이 raw 만으로는 `needs-confirmation` |
## Usage Boundaries / 적용 경계
- 이 자료가 직접 증명하는 것:
- `GOOGLE-WEBSERVER-C1`: web-server flow 의 대상은 confidential/stateful 애플리케이션
- `GOOGLE-WEBSERVER-C2`: Google Cloud Console 에서 "Web application" application type 을 명시적으로 선택해야 함
- `GOOGLE-WEBSERVER-C3`: server-side 애플리케이션은 authorized redirect URIs 등록 의무
- `GOOGLE-WEBSERVER-C4`: 토큰 교환 엔드포인트(`oauth2.googleapis.com/token`)와 예시 요청의 literal 파라미터 구성
- `GOOGLE-WEBSERVER-C5`: `client_secret` 의 출처(Cloud Console) 및 일반 파라미터 표상 Optional 라벨
- 이 자료가 증명하지 않는 것:
- "JavaScript origins 를 비워도 된다"는 명시적 문장은 이 문서에 **존재하지 않음** — 이 문서는 JavaScript origins 자체를 전혀 언급하지 않는다(구조적 침묵). branch D6 의 "JS origins 비움" 결정을 이 문서만으로 FACT 화할 수 없다 — `UNSUPPORTED_DECISION` 유지 필요.
- `client_secret` 이 web-server flow 에서 "항상 필수"라는 단정 — 일반 파라미터 표는 Optional 로 표기하며, flow별 필수 여부 구분은 이 인용 범위 밖.
- Keycloak 이 실제로 이 Google flow 규격을 완전히 준수해 구현되어 있는지 — 이 문서는 Google 측 사양만 다루고 Keycloak 구현을 증명하지 않음(Keycloak 측은 별도 raw, `keycloak-google-idp-setup` 참조).
- 내 프로젝트에 적용하려면 추가 확인이 필요한 것:
- Google Cloud Console 실제 OAuth client 생성 화면에서 "Web application" 선택 시 "Authorized JavaScript origins" 필드가 실제로 optional/비워둘 수 있는 UI 인지 스크린샷/실험으로 확인 필요.
- `client_secret` 이 web-server flow 컨텍스트에서 실제로 required 로 강제되는지 (Optional 라벨이 다른 flow 와 공유되는 범용 표라서 그런 것인지) Google Cloud Console 실제 등록 흐름으로 재확인 필요.
## 메모 / Notes
- 본 raw 는 WebFetch 결과를 근거로 작성됨 — WebFetch 는 HTML을 markdown 변환 + 소형 모델 요약을 거치므로, 진짜 byte-level HTML 원문은 아니다. 다만 verbatim 재현을 3회 별도 요청하여 핵심 문장을 교차 확인했고, self-grep 으로 저장된 fetch 텍스트와 일치함을 검증함.
- "JavaScript origins" 미언급은 fabrication 방지를 위해 의도적으로 "침묵"으로만 기록 — "비워도 된다"는 허용 문장으로 재구성하지 않음.
- 추가로 봐야 할 동일 출처 페이지: Google "Setting up OAuth 2.0" (Cloud Console credential 생성 UI 가이드), Google OAuth 2.0 Client ID application type 비교 페이지 — "Web application" vs 기타 type 차이 및 JavaScript origins 필드 조건을 다루는 페이지가 있는지 확인 필요.
## Related / 관련
- [[raw/official-docs/google-oauth2-redirect-uri-validation-official]] — Google redirect_uri 검증 규칙(exact match, HTTPS, wildcard 금지 등) 공식 문서. 본 문서와 함께 D1~D4, D6 근거.
- [[raw/official-docs/keycloak-google-idp-setup]] — Keycloak 측 Google IdP 등록 절차(Redirect URI 표시값, Client ID/Secret 입력 위치). 본 문서(Google 측 사양)와 짝을 이루는 Keycloak 측 절차 문서.
- 이 자료를 인용한 wiki 요약: (생성 시 추가)