Release: OpenRemote Postman API Collection with fix for OAuth Authentication

OpenRemote Manager REST API.postman_collection.json.txt (1.1 MB)
If you’re having any issues, make sure to rename the file from .txt to .json

Good evening everyone,

Attached you will find a collection.json file for the OpenRemote HTTP REST API. I have setup all of the required variables and Authentication to be able to make requests simply by importing the collection. You can see how to import the collection by clicking here.

To be able to make requests to the API, you will need to first go to the variables page and fill in all of the variables you see.

After setting the variables, go to the authentication tab of the root page of the collection, and press the “Get New Access Token”. If that is successful, then you are authenticated and can go make any request you would like.

There is a bug that I’ve identified, which prohibits keycloak from sending refresh tokens for OAuth authentication when authenticating via Client Credentials (what is used for Service Users). You can check that after getting a new OAuth token and then checking if a refresh token is included in the response.

Below are the steps to fix this:

  • Create your service user
  • Go onto the Keycloak web UI as admin (or any elevated user)
  • Make sure you are in the correct realm → Clients → [Your service client username] → scroll to the bottom → OpenID Connect Compatibility Modes → Use Refresh Tokens For Client Credentials Grant → turn this to ON.

Now, whenever you want to make a request, if the access token is expired, Postman will automatically request a new access token.

Thank you to Postman for releasing openapi-to-postmanv2, which is what made this possible.

Happy API development!

3 Likes

Correction, on the OAuth authentication process, make sure to change the access token URL to {{baseLocation}}/auth/realms/{{realm}}/protocol/openid-connect/token, so that you can connect to any realm.

1 Like

Thanks so much for sharing, this was really helpful!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

Happy to inform everyone that with pull request #1320, the OpenAPI schema for OpenRemote has been updated and can now produce valid OpenAPI schemas. This means that you can now directly import the OpenRemote API schema directly into postman, no need for the attached collection.json file.

1 Like

Good work @panos! What do you mean with “directly import the OpenRemote API schema directly into postman, no need for the attached collection.json file.”. Should I not use the file of your initial post? Which file should I use?

I think panos means this file:

Can confirm that it does implement into Postman directly, but the authorization settings have changed, couldnt get that to work so still using the authorization method from the original post?

Disregard the main post, just go onto any updated OpenRemote instance and copy the following link: {your OpenRemote hostname}/api/master/openapi.json. Then, press the import button on Postman, and paste the link in the textbox that appears. Postman will then parse the OpenRemote API schema as their own Postman collection and allow you to insert it to your list of collections.

Thanks! Instead of disregarding the main post, maybe you can update it? :wink:

1 Like

The authorization methods in our OpenAPI schema were updated to include both types of authentication (Client Credentials and Authorization code), for logging in with a service account and a normal account respectively. Because of that, Postman can’t really decide what to do so it leaves it to the user. If the user authorization you have works, you can use that :slight_smile:

1 Like