Skip to content

Instantly share code, notes, and snippets.

@iamssen
Created April 17, 2013 08:07
Show Gist options
  • Save iamssen/5402578 to your computer and use it in GitHub Desktop.
Save iamssen/5402578 to your computer and use it in GitHub Desktop.
OAuth2 로 github 로그인 처리 단계별 처리...

Github OAuth 참고

우선 https://github.com/settings/applications 에서 Application 에 등록된 정보들 확인

로그인처리

  1. get https://github.com/login/oauth/authorize?client_id={client_id}&redirect_uri={http://...} 형태로 어플리케이션 등록 정보를 바탕으로 앱 승인 주소로 날려보냄
  2. get http://ssen.name/devlog?code=x1aa07b850cbf6eeba1a 과 같은 형태로 code 를 보내주게 됨
  3. 받은 코드를 사용해서 post https://github.com/login/oauth/access_token 로 정보를 요청
  • header Accept : application/json
  • param code : {받은 코드}
  • param client_secret : {어플리케이션 정보에서 가져옴}
  • param client_id : {어플리케이션 정보에서 가져옴}
  • 정상 처리가 되면 status 200 으로 {access_token: "xed9x8e949fed8a8c9549809e84968be98712207", token_type: "bearer"} 과 같은 정보가 날라옴. 이 access_token 을 통해서 여러 API 에 접근 가능해짐
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment