cancel
Showing results for 
Search instead for 
Did you mean: 

OAuth2.0 Client Credentials Parameters

SOLVED
savarkaul
New Contributor

OAuth2.0 Client Credentials Parameters

Hi Team,

 

I'm fairly new to Swagger Editor and API documentation and I have to add a parameter to pass my access token in the API documentation. I am using OAuth 2.0 with Grant Type- Client Credentials. I am able to lock the APIs using the Authorize button on my Swagger's interactive UI but I need to view the generated access token on my interactive UI.and send it as a header parameter to specific APIs.

 

This is the security component I have added to my document:

 

components:
securitySchemes:
oAuth2ClientCredentials:
type: oauth2
flows:
clientCredentials:
tokenUrl: 'https://localhost:8081/oauth/token'
scopes: {}

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
savarkaul
New Contributor

Re: OAuth2.0 Client Credentials Parameters

Hi, @HKosova thanks for the help but I had already done that!

Actually, I was confused about needing a parameter to send the generated access token as a parameter but after some research, I have come to know that for the grant type, Client Credentials -> when we click on Authorize button, the generated access token gets embedded within the cURL and goes with the GET/POST call in the header, along with the other parameters specified in the documentation. 

View solution in original post

2 REPLIES 2
HKosova
Moderator

Re: OAuth2.0 Client Credentials Parameters

Hi @savarkaul, you also need to add "security" to individual operations or at the root level:

security:
  - oAuth2ClientCredentials: []

See https://swagger.io/docs/specification/authentication/oauth2/#config


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
savarkaul
New Contributor

Re: OAuth2.0 Client Credentials Parameters

Hi, @HKosova thanks for the help but I had already done that!

Actually, I was confused about needing a parameter to send the generated access token as a parameter but after some research, I have come to know that for the grant type, Client Credentials -> when we click on Authorize button, the generated access token gets embedded within the cURL and goes with the GET/POST call in the header, along with the other parameters specified in the documentation. 

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors