Comments (3)
There's no built-in function for refreshing a token in the HTML page. But if you run it locally with node.js it's super easy making your own, just using the cleaned-up teslaAuth.js library I added in the latest commit.
Clone or download the repository. Then create a refresh.js
file in the root (next to the teslaAuth.js
file), just containing something like this.
const teslaAuth = require("./teslaAuth");
const token = teslaAuth
.refreshToken("<<<YOUR REFRESH TOKEN>>>")
.then(t => console.log(t))
Run it with node refresh.js
The refresh call is a simple POST to the Tesla server. You can just curl it if you like.
curl --header "Content-Type: application/json" --data '{
"grant_type":"refresh_token",
"scope":"openid email offline_access",
"client_id":"ownerapi",
"refresh_token":"<<<YOUR REFRESH TOKEN>>>"
}' https://auth.tesla.com/oauth2/v3/token
from fetch-tesla-token.
The teslaAuth.js
file is all you need from my repository if you want to put the function in your own project. Just copy that single file and then you can use the authenticate
, refreshToken
, and ownerapiToken
functions. They're all documented inside the source.
fetch-tesla-token/teslaAuth.js
Lines 102 to 112 in 5c31098
fetch-tesla-token/teslaAuth.js
Lines 273 to 279 in 5c31098
fetch-tesla-token/teslaAuth.js
Lines 294 to 300 in 5c31098
from fetch-tesla-token.
The
teslaAuth.js
file is all you need from my repository if you want to put the function in your own project. Just copy that single file and then you can use theauthenticate
,refreshToken
, andownerapiToken
functions. They're all documented inside the source.fetch-tesla-token/teslaAuth.js
Lines 102 to 112 in 5c31098
fetch-tesla-token/teslaAuth.js
Lines 273 to 279 in 5c31098
fetch-tesla-token/teslaAuth.js
Lines 294 to 300 in 5c31098
That's great, thanks for taking the time to reply, I'll try it out in the morning (01:11 here)
from fetch-tesla-token.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fetch-tesla-token.