how to pass client credentials in postman?

主宰稳场 提交于 2021-02-07 03:41:38

问题


This curls works fine

curl acme:acmesecret@localhost:9999/uaa/oauth/token  -d "password=password&username=user&grant_type=password" -H "Accept: application/json"

In this curl, acme and acmesecret are client credentials used by application to authenticate with authorization server running in localhost:9999

I am trying to make the same request using postman (rest client for chrome).

Here is the screen shot (I entered credentials in Basic Auth tab)

Here is the preview of the request that is sent out: (NOTE: AUthorization basic header is added)

I am getting error as "invalid_client". how to fix this?

Thanks


回答1:


cURL

acme:acmesecret@localhost:9999/uaa/oauth/token

The acme:acmesecret is the HTTP client credentials sent in the basic auth header. You can add the -v switch to see the headers in the request.

-d "password=password&username=user&grant_type=password"

This is the form data.

In the Postman request, you have it switched around. You have the client credentials in the form data, and I'm guessing you have the user credentials in the auth header.

Just switch them. For an OAuth 2.0 password grant request, the client credentials should go in the auth header, while the user credentials go in the form data.




回答2:


I found this piece of information to be quite helpful from the Postman docs incase others needed more clarification.

Postman > Sending API Requests > Authorization

https://learning.getpostman.com/docs/postman/sending_api_requests/authorization/



来源:https://stackoverflow.com/questions/32276825/how-to-pass-client-credentials-in-postman

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!