Search code examples
postman

Change the variable name for client_id and/or client_secret in the authorization tab in Postman


I'm guessing the title is pretty self explanatory, but basically Jamf Protect will use "client_id" for, well, Client ID but instead of client_secret it expects "password".

I tried looking for different ways of manipulating that but couldn't.

For reference, I'm trying to use Oauth 2.0, and then have things changed under "Configure New Token".

Any knows how to do that?


Solution

  • On the Authorization tab within the Configure New Token section on the bottom you will find an accordion Advanced which you need to open. There will be a table where you can add arbitrary parameters to your token request. Here you can just add your password parameter:

    enter image description here

    When you have everything properly configured for Client Credentials flow and press Get New Access Token Postman will issue the token request with your custom parameter attached. Here I am using the Duende IdentityServer demo server to show it's working. See this screenshot of the Postman console:

    enter image description here

    Here the collection containing a single dummy request with OAuth2 configured which is what I used to get the result above.

    {
        "info": {
            "_postman_id": "cc66d2e4-cd99-4b68-a43d-117582e8f5aa",
            "name": "StackOverflow",
            "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
            "_exporter_id": "11128553"
        },
        "item": [
            {
                "name": "https://postman-echo.com/post",
                "request": {
                    "auth": {
                        "type": "oauth2",
                        "oauth2": [
                            {
                                "key": "client_authentication",
                                "value": "body",
                                "type": "string"
                            },
                            {
                                "key": "accessTokenUrl",
                                "value": "https://demo.duendesoftware.com/connect/token",
                                "type": "string"
                            },
                            {
                                "key": "scope",
                                "value": "api",
                                "type": "string"
                            },
                            {
                                "key": "clientSecret",
                                "value": "secret",
                                "type": "string"
                            },
                            {
                                "key": "clientId",
                                "value": "m2m",
                                "type": "string"
                            },
                            {
                                "key": "tokenRequestParams",
                                "value": [
                                    {
                                        "key": "password",
                                        "value": "<your client secret>",
                                        "enabled": true,
                                        "send_as": "request_body"
                                    }
                                ],
                                "type": "any"
                            },
                            {
                                "key": "tokenName",
                                "value": "testtoken",
                                "type": "string"
                            },
                            {
                                "key": "grant_type",
                                "value": "client_credentials",
                                "type": "string"
                            },
                            {
                                "key": "addTokenTo",
                                "value": "header",
                                "type": "string"
                            }
                        ]
                    },
                    "method": "POST",
                    "header": [],
                    "body": {
                        "mode": "raw",
                        "raw": "\"some test body\"",
                        "options": {
                            "raw": {
                                "language": "json"
                            }
                        }
                    },
                    "url": {
                        "raw": "https://postman-echo.com/post",
                        "protocol": "https",
                        "host": [
                            "postman-echo",
                            "com"
                        ],
                        "path": [
                            "post"
                        ]
                    }
                },
                "response": []
            }
        ]
    }