[program-l] Re: How can I test an API using a bearer token?

  • From: jacob kruger <jacob.kruger.work@xxxxxxxxx>
  • To: program-l@xxxxxxxxxxxxx
  • Date: Thu, 3 Nov 2022 08:50:57 +0200

Eric, chances are you need to pass an authorization token in request headers?


With python requests module - code snippets here:

import requests
s_token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJJRCI6MSwidl91c2VyX2lkIjoicm9nZXIifQ.GYPdAGEnnruVNCd69ZUe5e22l_PBlLIMoVz1KSAlogk"
http_headers = { "Authorization": s_token}

# ...

rp = requests.get(s_url, headers=http_headers)

# end code


HTH




Jacob Kruger
+2782 413 4791
"Resistance is futile...but, acceptance is versatile..."


On 2022/11/02 02:16, Eric Brinkman wrote:

I'm being asked to test a MuleSoft endpoint by authenticating with a key and secret, obtaining a bearer token, and then using the token to log in and send data to the endpoint.  My co-workers are using Postman to do this, but that app is not accessible.  I've installed Thunder Client for VS Code but can not figure out how to get it to do this.  Reading my co-worker's Postman script just confuses me.  I've been told I need to use an app that supports API key authentication.  Do any of you know how to do this?

Thanks,
Eric
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts: