I'm currently trying to obtain an OAuth2 token to authenticate for an external service (Snowflake database), but I'm running into some problems with this.
According to the documentation, this is supposed to work:
oauth2_token = New OAuth2 Token(
User( username ),
Password( password),
Client ID( client_id ),
Client Secret( client_secret ),
Token URL( "http://localhost:8008" ),
Grant Type("password"),
Scope("session:role-any")
);
However, whenever I run this, I get back an HTTP/1.1 400 Bad Request INVALID_REQUEST:INVALID_REQUESTDESCRIPTION
To debug this, I started a locally running HTTP echo server and sent requests from Python (working code, verified with real OAuth2 server) and JMP, and I got back this:
Python
127.0.0.1 - - [05/Feb/2025 13:36:00] "POST / HTTP/1.1" 200 -
Host: localhost:8008
User-Agent: python-requests/2.32.3
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Content-Length: 91
Content-Type: application/x-www-form-urlencoded
Authorization: Basic <redacted>=
grant_type=password&username=<redacted>&password=<redacted>&scope=session%3Arole-any
JMP 17
127.0.0.1 - - [05/Feb/2025 13:36:56] "POST / HTTP/1.1" 200 -
Host: localhost:8008
User-Agent: libcurl-agent/1.0 (Windows NT 10.0.22631;x64)
Accept: */*
Content-Length: 102
Content-Type: application/x-www-form-urlencoded
client_id=<redacted>&redirect_uri=&response_type=token&scope=&state=<redacted>
As you can see, there's no Authorization header, and also, most of the request parameters (grant type, username, password, scope) are missing.
To me, it looks like JMP generates a bogus request, and therefore, the communication with the server fails. Is this assumption correct? Or am I doing something wrong?
Any help would be highly appreciated.
Kind regards
Frank