python oauth2 openid connet token verify 하는방법
프로그래밍 언어 및 기타/Python

python oauth2 openid connet token verify 하는방법

https://developers.google.com/identity/openid-connect/openid-connect

 

OpenID Connect  |  Authentication  |  Google Developers

이 페이지는 Cloud Translation API를 통해 번역되었습니다. Switch to English 의견 보내기 OpenID Connect 컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요. Google의 OAuth 2.0 AP

developers.google.com

 

 

https://google-auth.readthedocs.io/en/master/reference/google.oauth2.id_token.html?highlight=verify_oauth2_token#google.oauth2.id_token.verify_oauth2_token 

 

google.oauth2.id_token module — google-auth 1.30.0 documentation

google.oauth2.id_token module Google ID Token helpers. Provides support for verifying OpenID Connect ID Tokens, especially ones generated by Google infrastructure. To parse and verify an ID Token issued by Google’s OAuth 2.0 authorization server use veri

google-auth.readthedocs.io

 

 

위 위 링크의 요지는 구글에서 로그인용 jwt token 정보를 넘겨주지만 이게 진짜 구글에서 왔는지를 구글의 공개키를 확인해서 감지하는 거임. 공개키 비밀키의 무결성 확인용인듯.

 

 

그래서 좀 찾아보면

https://www.googleapis.com/oauth2/v3/certs

https://www.googleapis.com/oauth2/v1/certs

 

v3/certs 링크에 공개키 인증서 이름있고, 인증서 내용은 v1/certs에 있음.

이거하고 내 앱 클라이언트 아이디를 토큰의 aud랑 비교만 하면 내 앱인거 확인 될듯하다.

 

 

실제 라이브러리 가보면 저런걸 확인하는 방식으로 진행됨.

 

=====

https://googleapis.dev/python/google-auth/latest/reference/google.auth.jwt.html

 

google.auth.jwt module — google-auth 2.15.0 documentation

google.auth.jwt module JSON Web Tokens Provides support for creating (encoding) and verifying (decoding) JWTs, especially JWTs generated and consumed by Google infrastructure. See rfc7519 for more details on JWTs. To encode a JWT use encode(): from google.

googleapis.dev

 

이 token decode는 단순 구글 로그인 말고 다른 구글 API(유저의 드라이브 불러오기, 지도 불러오기 등)을 사용할 때 IMA 해서 받아서 하는거. 이것때문에 헷갈렸다.