5

I'm using OAuthToolkit and DjangoRestSwagger. I've created an application using Django Admin, and now I've client_id and client_secret.

I want to generate the token using client_id and client_secret. Currently, I use curl to generate the token.

curl -X POST -d "grant_type=client_credentials" -u"client_id:client_secret" http://localhost:8000/o/token/

How can I do it using the Swagger docs.? Basically, how can integrate third party(OAuthToolkit) API URLs with Swagger?

Currently, I've an Authorize button which takes api_key value, ie the token.

Here's my Swagger settings.

SWAGGER_SETTINGS = {
    'SECURITY_DEFINITIONS': {
        'token': {
            'type': 'apiKey',
            'name': 'AUTHORIZATION',
            'in': 'header',
        }
    },
}
Praful Bagai
  • 16,684
  • 50
  • 136
  • 267

1 Answers1

1

Not certain about django-rest-swagger but if you are looking for an alternative with gauranteed support for oauth you can use drf-yasg (yet another swagger generator)

Documentation for yasg adding oauth paths to swagger

tread
  • 10,133
  • 17
  • 95
  • 170