Coder Social home page Coder Social logo

ryanrodemoyer / djangorestoauthangulartemplate Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 545 KB

Template project using Django/DRF/OAuth on the backend and Angular 5 on the frontend.

License: MIT License

TypeScript 60.71% JavaScript 3.85% HTML 18.37% CSS 0.36% Python 16.71%
django django-oauth angular django-rest-framework

djangorestoauthangulartemplate's Introduction

FOR NOW THIS DOCUMENTATION IS INCORRECT

Django Oauth Example

About

This is a small app for an example of how to configure together Django, Django REST Framework and Django Oauth Toolkit.

Requirements

  • Python 3.6.3

Install

  1. Clone project.
    git clone [email protected]:ryanrodemoyer/DjangoOauthExample.git
  2. Switch directory
    cd DjangoOauthExample
  3. Install requirements.
    pip install -r requirements.txt
  4. Migrate database.
    python manage.py migrate
  5. Create user.
    python manage.py createsuperuser
  6. Run!
    python manage.py runserver

Usage

Views

  1. Admin Login @ http://localhost:8000/admin.
  2. Register/View applications @ http://localhost:8000/o/applications.
  3. Token endpoint @ http://localhost:8000/o/token

Getting A Token

Authorization Code

  1. Register new application.
  2. Follow the steps @ http://django-oauth-toolkit.herokuapp.com/consumer/ to get a token.
  3. Verify /api/users/ route is protected.
    curl http://localhost:8000/api/users/.
  4. Request /api/users/ to see data.
    curl -H "Authorization: Bearer <your_access_token>" http://localhost:8000/api/users/

Resource Owner Password

  1. Register new application
    • Name: <your choice>.
    • Client type: confidential.
    • Authorization grant type: Resource owner password-based.
    • Redirect urls: <blank>
  2. Verify /api/users/ route is protected.
    curl http://localhost:8000/api/users/
  3. Get a token. Use the super user credentials from above in Install or create a new user via Django Admin and use those credentials.
    curl -X POST -d "grant_type=password&username=<user_name>&password=<password>" -u "<client_id>:<client_secret>" http://localhost:8000/o/token/
  4. Request /api/users/ to see data.
    curl -H "Authorization: Bearer <your_access_token>" http://localhost:8000/api/users/

Credits

Based mostly on the documentation at https://django-oauth-toolkit.readthedocs.io.

Projects

djangorestoauthangulartemplate's People

Contributors

ryanrodemoyer avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.