For details see requirements.txt!
- Django (v.1.6)
- Tastypie REST API (
django-tastypie
) - OAuth2 (
django-oauth2-provider
) - Tastypie Swagger (
django-tastypie-swagger
)
- Tastypie REST API (
Used files
- OAuth 2.0 authentication model for Tastypie by Ian Alexander (
sample_server/authentication.py
) - Django middleware for cross-domain XHR by strogonoff (
sample_server/django-crossdomainxhr-middleware.py
)
-
Create database tables with sample data and a superuser
python manage.py syncdb
-
Run server
python manage.py runserver
Admin site: http://localhost:8000/admin/
-
Run one of the clients
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