cancel
Showing results for 
Search instead for 
Did you mean: 

OAuth via Auth0 with a JWT

Highlighted
New Contributor

OAuth via Auth0 with a JWT

My application's UI authenticates with Auth0 and sends a JWT with each request to my server in the Authorization header.

How do I achieve this behavior with swagger ui? I am hosting my Swagger UI using the swagger-ui-express node.js module. 

I am able to get Swagger UI to authenticate with Auth0 using the following security definition:

securityDefinitions:
auth0:
type: oauth2
flow: authorizationCode
authorizationUrl: https://XXX.auth0.com/authorize
tokenUrl: https://XXX.auth0.com/oauth/token
scopes: {}

And swagger even passes a value in the Authorization (bearer) header of my requests.. But, the bearer token does not appear to be a JWT, which my server is expecting.

9 REPLIES 9
Community Hero

Re: OAuth via Auth0 with a JWT

Not sure if this helps!

How do I test the service if no Swagger UI?
Alternatives SoapUI or Postman or write code to test, I can think of where you can generate JWT token and pass it as header parameter.


Regards,
Rao.
New Contributor

Re: OAuth via Auth0 with a JWT

I'm not seeing the relevance...

Community Hero

Re: OAuth via Auth0 with a JWT

No worries!


Regards,
Rao.
Community Hero

Re: OAuth via Auth0 with a JWT

I thought you wanted to find an alternative way to test the service. Isn't it?


Regards,
Rao.
New Contributor

Re: OAuth via Auth0 with a JWT

No, I'm not looking for an alternative way. I'm looking for the right way to do this *using* Swagger.

Community Hero

Re: OAuth via Auth0 with a JWT

May be see if the below is relevant
https://github.com/swagger-api/swagger-ui/issues/2915


Regards,
Rao.
Occasional Contributor

Re: OAuth via Auth0 with a JWT

I'd love to see a reply to this.

New Contributor

Re: OAuth via Auth0 with a JWT

This did not end up helping me. It seems this is a fundamental flaw with swagger-ui and I just need to wait for them to support more oauth methods.

Re: OAuth via Auth0 with a JWT

@kbcb, are you sure your Auth0 instance is configured to hand back an Access Token as a JWT?

 

Swagger UI just uses token that it is given by the tokenUrl, so this is probably an issue with your auth provider.

New Here?
Join us and watch the welcome video:
API Testing Mistake #2
APITestingMistake#2
Top Kudoed Authors