Hey there. Attempting to build a browser-based integration but having some trouble getting an access token.
This cURL command works:
curl -X POST -d 'grant_type=password&username=MY_USERNAME&password=MY_PASS&client_id=MY_ID&client_secret=MY_SECRET' https://beta.online-go.com/oauth2/token/
I get an access token just fine.
This fetch() does not:
function getAccessToken() {
var theBody = JSON.stringify({
grant_type: 'password',
username: OGS_USERNAME,
password: OGS_PASSWORD,
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
});
fetch(`https://${BETA ? 'beta.' : ''}online-go.com/oauth2/token/`, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: theBody,
})
.then(response => response.json())
.then(data => {
console.log(data);
});
}
I get {error: “unsupported_grant_type”}. Is this a CORS issue in disguise? Something I’m missing? Everything else is identical as far as I can tell. My oauth2 application settings are Client typepublic and Authorization Grant Typepassword.
Any help would be appreciated! Tagging in @flovo and @matburt