This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Help with Tesla Powerwall API V3
#25
(27.01.2022, 09:41)admin Wrote: Try adding User-Agent/X-Tesla-User-Agent headers as in previous examples. Also try adding client_secret field to the JSON body. You might also need an additional request to exchange bearer token for access token.

I already tried that, but same 400 deny error

Code:
function GetToken()
  body = json.encode({
    grant_type = 'authorization_code',
    client_id = 'ownerapi',
    client_secret = client_secret,
    refresh_token = refreshToken,
    scope = 'openid email offline_access'     
  })

  resp = {}

  res, code, headers = http.request({
    url = 'https://auth.tesla.com/oauth2/v3/token',
    method = 'POST',
    source = ltn12.source.string(body),
    sink = ltn12.sink.table(resp),
    headers = {
      ['Content-Type'] = 'application/json',
      ['Accept'] = 'application/json',
      ['Content-Length'] = #body,
      ['User-Agent'] = 'Mozilla/5.0 (Linux; Android 9.0.0; VS985 4G Build/LRX21Y; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/58.0.3029.83 Mobile Safari/537.36',
        ['X-Tesla-User-Agent'] = 'TeslaApp/3.4.4-350/fad4a582e/android/9.0.0'
    }
  })
 
  log(res, code, headers)
end
Reply


Messages In This Thread
Help with Tesla Powerwall API V3 - by jamesng - 21.04.2021, 14:18
RE: Help with Tesla Powerwall API V3 - by gjniewenhuijse - 27.01.2022, 11:10

Forum Jump: