Get API OAuth token using HTTP Request app

Post Reply
wkopp
Member
Posts: 25
Joined: Mon Sep 16, 2019 8:20 pm

Get API OAuth token using HTTP Request app

Post by wkopp »

Hello everyone,

I'm trying to get an API Token using the HTTP request app but I don't have any experience in this area. I have tested the connection and details using Postman and that works fine. I just don't know where to include that info in the HTTP request app. I haven't found any good details for using the app. Apparently they expect the user to have some idea of what they're doing. :) (Once I get the token I'll need to use it in a second http request to get info from an API.)

This is what I have in Postman Authorization Settings (actual URL and credentials have been replaced):

- Configure New Token section -
Token Name: bearer
Grant type: Client Credentials
Access Token URL: https://myurl.com/OmsIdentityServer/connect/authorize
Client ID: myclientID
Client Secret: myclientSecret
Scope: myScope
Client Authentication: Send as Basic Auth header


This is what I have in the Switch HTTP request Settings:

URL: https://myurl.com/OmsIdentityServer/connect/authorize
Request Type: GET
Authentication scheme: OAuth
Authorization: client_id=myclientID client_secret=myclientSecret
Parameters:
scope=myScope
Headers:
<none>
Response: Inject as new job

Any help will be greatly appreciated!
Thanks as always...
freddyp
Advanced member
Posts: 1135
Joined: Thu Feb 09, 2012 3:53 pm

Re: Get API OAuth token using HTTP Request app

Post by freddyp »

In Postman I do not find the authorization "Send as Basic Auth header". There is "Basic Auth", but that requires a username and a password and is probably not what you need. I suggest that you export the Postman settings as a JSON and upload it here (you may have to zip it). It is of course OK to use fake values.
wkopp
Member
Posts: 25
Joined: Mon Sep 16, 2019 8:20 pm

Re: Get API OAuth token using HTTP Request app

Post by wkopp »

Here's the export from Postman.

I've been hunting around for answers and it looks like I should be using a POST method instead of GET. I've tried combinations of putting credentials in a json file for the "Attached file" as well as adding them in Parameters or Headers sections but no luck so far.

I appreciate you taking a look freddy...
Attachments
Token Generated.postman_collection.zip
(711 Bytes) Downloaded 6 times
freddyp
Advanced member
Posts: 1135
Joined: Thu Feb 09, 2012 3:53 pm

Re: Get API OAuth token using HTTP Request app

Post by freddyp »

The Postman request uses "OAuth 2.0" as the authentication method, so that is also the one that you should use in Switch. Setting up OAuth 2.0 is not for the faint of heart. You need some information about the service you are connecting to: application ID, application password, authorization url, token url, and scope. You also often have to register Switch with the service you are using.

To confuse things even more the OAuth terminology often differs from system to system, so you will have to experiment a bit, e.g. what is Access Token URL in your post probably goes into "Token URL" and Scope into "Scope", but what to do with Client ID and Client Secret?
Post Reply