sungmin306 / kakaooauth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

django oauth

django rest framework의 APIView와 drf-yasg를 이용한 swagger API로 oauth 테스트 구현

Setting

1. 가상환경 생성 및 접속

> python -m venv venv
> venv\Scripts\activate

2. 라이브러리 설치

(venv)> pip install -U pylint
(venv)> pip install django

# restframework
(venv)> pip install djangorestframework
(venv)> pip install djangorestframework-simplejwt

# oauth
(venv)> pip install requests
(venv)> pip install pyjwt[crypto]

# swagger
(venv)> pip install drf-yasg

3. oauth 사이트 설정 및 설명

4. 서버 실행

> cd source
> python manage.py makemigrations
> python manage.py migrate
> python manage.py runserver localhost:8000

5. client 테스트

  • 설정파일에 지정한 oauth의 REDIRECT_URI주소로 웹브라우저로 접속한다.
  • oauth 로그인이 정상적으로 완료되면 {"social_id": ..., "access_token": ..., "refresh_token": ...} 값이 반환된다.
  • http://localhost:8000/swagger/ 접속하여 우측상단에 Authorize버튼 클릭한다.
  • 방금전에 발급받은 access_token을 입력하고 Authorize버튼 클릭한다.
  • users의 GET /users/info/ 요청을 전송하면 사용자의 정보가 출력된다.

About


Languages

Language:Python 100.0%