401 Unauthorized response on initial attempt
Closed this issue · 2 comments
Hi, I've just begun experimenting with the module; version 2.3.21 installed from npm.
I'm consistently seeing 401 Unauthorized responses when trying to perform API calls. My initial request was:
import OnStar from "onstarjs";
import {v4} from 'uuid';
const onstar = OnStar.create({
deviceId: v4(),
onStarPin: PIN,
username: ID,
password: PW,
vin: VIN
});
async function main() {
try {
const diag = await onstar.getAccountVehicles();
console.log(diag.status)
} catch (e) {
console.log(e);
console.error('failed');
}
}
main();
The error I'm getting back: RequestError: Request Failed with status 401 - Unauthorized
The request URL is a POST against 'https://api.gm.com/api/v1/oauth/token', but I haven't tried decoding the payload.
My initial thought was that 2FA might be affecting things; my GM account is protected with a TOTP authenticator. But I tried disabling 2FA, and am still seeing the same issue.
Any idea on how to best troubleshoot? I'm using my gm.com credentials; as I never setup anything explicitly for OnStar. Would I need to have set something specifically up for that?
Decoding the /token JWT payload, it appears to be failing on the password grant request:
{
"client_id": "OMB_CVY_AND_6G0",
"device_id": "XXX",
"grant_type": "password",
"nonce": "XXX",
"password": "XXX",
"scope": "onstar gmoc user_trailer user priv",
"timestamp": "2023-04-26T14:54:15.001Z",
"username": "XXX"
}
Going back to this, I realize I was using an old password, whoops :/
I'm able to query successfully now.