sitelink1 | https://choiseokwon.tistory.com/389 |
---|---|
sitelink2 | |
sitelink3 | |
sitelink4 | |
extra_vars5 | |
extra_vars6 |
간단히 각 플랫폼마다 로그인하고 유저 정보를 조회하는 방법이다.
OAuth2 클라이언트 아이디와 리다이렉트 경로가 필요하다.
- https://accounts.google.com/o/oauth2/v2/auth 에 forward, 코드 요청하고 (params: redirect_uri, client_id, access_type, response_type, prompt, scope, state (주로 리다이렉트 경로 + csrf) )
- https://oauth2.googleapis.com/token 에 POST, 토큰 얻고 (params: grant_type=authorization_code, redirect_uri, client_id, code, client_secret)
- https://www.googleapis.com/oauth2/v1/userinfo 에 GET, 유저 정보를 얻는다. (token에서 받은 ID Token으로 Bearer Auth + Access Token)
Github
OAuth2 클라이언트 아이디와 리다이렉트 경로가 필요하다.
- https://github.com/login/oauth/authorize 에 forward, 코드 요청하고 (params: redirect_uri, client_id, access_type, scope, state (주로 리다이렉트 경로 + csrf) )
- https://github.com/login/oauth/access_token 에 POST, 토큰 얻고 (params: client_id, code, client_secret, 이때 Accept: application/json 하면 json으로 쉽게 받을 수 있음)
- https://api.github.com/user 에 GET, 유저 정보를 얻는다. (Bearer Auth (access token), User-Agent를 아무거나로 설정 안 하면 404 뜨는 것 같다)
네이버 (https://developers.naver.com/docs/login/web/web.md)
OAuth2 클라이언트 아이디와 리다이렉트 경로가 필요하다.
- https://nid.naver.com/oauth2.0/authorize 에 forward, 코드 요청하고 (params: redirect_uri, client_id, state (주로 리다이렉트 경로 + csrf), response_type(code) )
- https://nid.naver.com/oauth2.0/token 에 POST, 토큰 얻고 (params: grant_type=authorization_code, redirect_uri, client_id, code, client_secret)
- https://openapi.naver.com/v1/nid/me 에 GET, 유저 정보를 얻는다. (Access Token으로 Bearer Auth)
카카오 (https://developers.kakao.com/docs/latest/ko/kakaologin/rest-api)
OAuth2 클라이언트 아이디와 리다이렉트 경로가 필요하다. 응답 JSON이 괴랄하다
- https://kauth.kakao.com/oauth/authorize 에 forward, 코드 요청하고 (params: redirect_uri, client_id (REST API 키), response_type, state (주로 리다이렉트 경로 + csrf) )
- https://kauth.kakao.com/oauth/token 에 POST, 토큰 얻고 (params: grant_type=authorization_code, redirect_uri, client_id (REST API 키), code)
- https://kapi.kakao.com/v2/user/me 에 GET, 유저 정보를 얻는다. (Access Token으로 Bearer Auth)