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
#23
(27.01.2022, 07:26)admin Wrote: Refresh token is what you use to get a new access and refresh token pair. Access token is used for API calls. It might have already expired so you need to generate a new token pair.
You will need a scheduled script to refresh the token periodically. See this for more info: https://tesla-api.timdorr.com/api-basics...cess-token

i changed the code a little bit, but always received a deny from the webservice

Code:
function GetToken()
  body = json.encode({
    grant_type = 'authorization_code',
    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
    }
  })
 
  log(res, code, headers)
end

As refreshToken i used the Refresh Token from the Auth for Tesla app.

When i hardcoded the Access Token in the code it works, but this code expires in 8 hours
Code:
function GetToken()
  return accessToken --from the Auth for Tesla app
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, 09:24

Forum Jump: