Skip to content
This repository has been archived by the owner on Jan 18, 2019. It is now read-only.

Latest commit

 

History

History

server

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Django sample server

Django REST/JSON server with OAuth2

Used software

For details see requirements.txt!

Used files

Run

  1. Create database tables with sample data and a superuser python manage.py syncdb

  2. Run server python manage.py runserver

    Admin site: http://localhost:8000/admin/

    API: http://localhost:8000/api/v1/

  3. Run one of the clients

Notes

OAuth2 - Get access token

Create client

python manage.py shell
 >>> from provider.oauth2.models import Client
 >>> from django.contrib.auth.models import User
 >>> u = User.objects.get(id=1)
 >>> c = Client(user=u, name="mysite client", client_type=1, url="http://exampple.com")
 >>> c.save()
 >>> c.client_id
'd63f53a7a6cceba04db5'
 >>> c.client_secret
'afe899288b9ac4127d57f2f12ac5a49d839364dc'
 >>> exit()

Get access token

curl -d "client_id=CLIENT-ID&client_secret=CLIENT-SECRET&grant_type=password&username=USERNAME&password=PASSWORD&scope=write" http://localhost:8000/oauth2/access_token