I have a requirement to invoke an API using OAuth2 authentication with base64 encryption.
Is this possible using HTTPAPI.
Any help appreciated. Thanks
I create manually the document:
POST /oauth2/hi-tech-health/authorize HTTP/1.1
Host: auth.mymedicalshopper.com
Authorization: Basic credential in base64
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
Trying to *post the request and I had 13 HTTP/1.1 400 Bad Request
API using OAuth2 authentication with base64 encryption
API using OAuth2 authentication with base64 encryption
- Attachments
-
- HTTPAPI command
- Capture 00.JPG (120.84 KiB) Viewed 199 times
-
- Site Admin
- Posts: 896
- Joined: Sun Jul 04, 2021 5:12 am
Re: API using OAuth2 authentication with base64 encryption
Base64 is not encryption. Do you mean base64 encoding? Or do you mean you need to do some sort of (unspecified) encryption and then encode the result with base64?fauSKriv wrote: Tue Jul 29, 2025 5:06 pm I have a requirement to invoke an API using OAuth2 authentication with base64 encryption.
Is what possible? I don't know what you are trying to do. I have an open source base64 tool, and there is also some limited use base64 routines in HTTPAPI as well. I can't say if they will do what you need, since you haven't told us what you need.
This is not a document.fauSKriv wrote: Tue Jul 29, 2025 5:06 pm I create manually the document:
POST /oauth2/hi-tech-health/authorize HTTP/1.1
Host: auth.mymedicalshopper.com
Authorization: Basic credential in base64
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
The start of it (POST, Host:, Authorization:, Content-Type:) are part of the HTTP protocol. You should never be doing that manually unless you are writing your own HTTP software.
The last line "grant_type=client_credentials" looks like a part of a URL-encoded form, but you've put it in the headers instead of in the request body, so 100% of the time this will generate a "400 Bad Request" response -- because it is not valid to put it there.
Start by deciding if you want to do it all yourself manually, or if you want to use HTTPAPI. Also decide the requirements for what you need to do with base64. If it is Basic authorization, you don't need to code that yourself, just use http_setAuth