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
#26
problem found, grant_type incorrect transfered

Code:
function GetToken()
  body = json.encode({
    grant_type = 'refresh_token',
    client_id = 'ownerapi',
    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   
      }
  })
  if not res or code ~= 200 then
    return
  end
  resp = table.concat(resp)
  resp = json.pdecode(resp)
 
  bearer_token = resp.access_token
  --refresh_token = resp.refresh_token
 
    return bearer_token
end

And next? do i need to refresh some tokens?
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, 13:02

Forum Jump: