Problem
I’m trying to get an access token for a given user via Resource Owner Password flow, but my request to https://MY-APPS-DOMAIN/oauth/token
keeps failing with a generic 500 status code.
Rough Setup
- Application (“App”) setup as machine-to-machine with Token Endpoint Auth Method set to
POST
- API (“API”) setup and authorized for “App”
- User created
Code Sample (.NET)
In code, I’m attempting to call the token endpoint using the Resource Owner Password grant type, but I keep getting a 500. Here’s a sample of what I’m doing:
var body = new Dictionary<string, string>
{
{"client_id", <client ID of App>},
{"client_secret", <client secret of App>},
{"audience", <Identifier of API>},
{"grant_type", "password"},
{"username", <username of a created user>},
{"password", <password of a created user>},
}
var requestContent = new FormUrlEncodedContent(body);
var response = await httpClient.PostAsync("https://MY-APP-DOMAIN/oauth/token", requestContent);
// response.StatusCode == 500
Is this flow not possible with a Machine-to-Machine app? Am I missing something else, somewhere… somehow?
Edit
I’ve also confirmed that the given user info works via the Try Connection tab for my Authentication Connection.