jsgoecke / tesla

Provides a wrapper around the API to easily query and command a Telsa car. As of now this has been used with a Model S, a Model X, and a Model 3.
MIT License
325 stars 73 forks source link

Commands return 403 - Forbidden #45

Closed sushi86 closed 10 months ago

sushi86 commented 10 months ago

Hey,

I can succesfully login and retrieve vehicle information, but as soon as I want to send a command like start charging or lock doors, I get "403 Forbidden".

I created the access_token and refresh_token via the iOS App "Auth for Tesla".

Do I need something else?

Example Code:

c, err := tesla.NewClient(ctx, tesla.WithTokenFile(tokenPath))
    if err != nil {
        return err
    }

    vehicles, err := c.Vehicles()
    if err != nil {
        return err
    }

    for i, v := range vehicles {
        if i > 0 {
            fmt.Println("----")
        }

        wakeup, err := v.Wakeup()
        if err != nil {
            fmt.Println("Wake up err")
            fmt.Println(err)
        }

        fmt.Println(wakeup)

        fmt.Printf("ID: %x\n", v.ID)
        fmt.Printf("Name %s\n", v.DisplayName)

        enabled, err := v.MobileEnabled()
        fmt.Println(enabled) <--- True
        if err != nil {
            fmt.Println("mobile enabled err")
            fmt.Println(err)
        }

        err = v.LockDoors() <--- 403 Forbidden
        if err != nil {
            return err
        }

Thanks for your help!