When trying try await Tesla.api.getAllData(vehicle).chargeState, I keep getting networkError(error: Error Domain=TeslaError Code=403 "(null)" UserInfo={ErrorInfo=TeslaSwift.ErrorMessage}), and I can't find out why.
API is authenticated, and it used to work. It stopped working without changes in the app. Must be due to a change on Tesl API side.
This is what I am doing:
static var api = TeslaSwift(teslaAPI: TeslaAPI.fleetAPI(
region: .europeMiddleEastAfrica,
clientID: clientID,
clientSecret: clientSecret,
redirectURI: redirectURI,
scopes: [
.openId,
.offlineAccess,
.vehicleDeviceData,
.vehicleCmds
]
))
api.reuse(token: token)
guard modelData.teslaAuthenticated else { return }
let vehicles = try await Tesla.api.getVehicles()
let vehicle = vehicles[0]
Task { @MainActor in
do {
let chargeState = try await Tesla.api.getAllData(vehicle).chargeState
} catch {
print (error)
}
}
→ Fails with networkError(error: Error Domain=TeslaError Code=403 "(null)" UserInfo={ErrorInfo=TeslaSwift.ErrorMessage})
Enabled Fleet API Scopes:
- Vehicle Information
- Vehicle Location
- Vehicle Commands
Not enabled: Vehicle Charging Management. Is this needed and maybe the culprit?
Any help is appreciated.