Reputation: 2900
I need to generate an API token for my app. The docs from the external service shows me below info:
This request uses normal post webforms.
<password> must be md5 encoded.
Endpoint: api/token
Request: "grant_type: password
Password: <password>
Username: <USERNAME>
"
What I did was generate md5 encoded password in console:
> Digest::MD5.hexdigest("ZCW2OQo5yhfmTKutGjiCWQ==")
=> "53a89a22375a3665cfe4cb92ee17992b"
And put it into curl command like below:
curl -d "grant_type=password&password=53a89a22375a3665cfe4cb92ee17992b&username=my_user_name" -X POST https://enpoint/api/token
But instead of expected response I'm getting an error:
{"error":"invalid_grant"}
Upvotes: 0
Views: 399
Reputation: 16435
It seems that your password is already encoded in some way - it's a base64 encoding of a binary string.
Try to put your actual password instead of this already encoded version as argument of hexdigest
.
Upvotes: 1