tesla_api 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/docs/api-basics/authentication.md +61 -12
- data/lib/tesla_api/client.rb +1 -1
- data/lib/tesla_api/vehicle.rb +3 -2
- data/lib/tesla_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f11d922517791fd73cf99ac8ce3a350191ffb377995dedb2282427a5f97d668d
|
4
|
+
data.tar.gz: ff687a34dc10b5372a9746d4686915b5209d0fb6b6ce68fcb10da0ba4314d68e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 864a284c2c7ddb0007ba9b4e56ef75a6796747159e3a69a4cf2dcf7803bec6899cffc198f70db21b18c6cc84a78e16708a35570a2af16fb38c521eac3bce5bd7
|
7
|
+
data.tar.gz: 328b0f263ef244d0e3ce5ca04b7707a177583647dea27fc7afcb7423230b8687a34b1a70c23bedfe03f32f1d245f27aabd550047d2c61c692f5494cc528483e0
|
@@ -4,7 +4,9 @@ description: The authentication process for the Tesla API
|
|
4
4
|
|
5
5
|
# Authentication
|
6
6
|
|
7
|
-
|
7
|
+
## POST `/oauth/token?grant_type=password`
|
8
|
+
|
9
|
+
The initial authentication process is via [an OAuth 2.0 Password Grant](https://oauth.net/2/grant-types/password/) with the same credentials used for tesla.com and the mobile apps.
|
8
10
|
|
9
11
|
The current client ID and secret are [available here](https://pastebin.com/pS7Z6yyP).
|
10
12
|
|
@@ -14,27 +16,74 @@ You will get back an `access_token` which is treated as [an OAuth 2.0 Bearer Tok
|
|
14
16
|
Authorization: Bearer {access_token}
|
15
17
|
```
|
16
18
|
|
17
|
-
|
19
|
+
The access token has a 45 day expiration.
|
18
20
|
|
19
21
|
### Request parameters
|
20
22
|
|
21
|
-
| Field
|
22
|
-
|
|
23
|
-
| `grant_type`
|
24
|
-
| `client_id`
|
25
|
-
| `client_secret` | String, required | `123`
|
26
|
-
| `email`
|
27
|
-
| `password`
|
23
|
+
| Field | Type | Example | Description |
|
24
|
+
| :-------------- | :--------------- | :--------------------- | :------------------------------------------------ |
|
25
|
+
| `grant_type` | String, required | `password` | The type of OAuth grant. Always "password" |
|
26
|
+
| `client_id` | String, required | `abc` | The OAuth client ID |
|
27
|
+
| `client_secret` | String, required | `123` | The OAuth client secret |
|
28
|
+
| `email` | String, required | `elon@teslamotors.com` | The email for the authenticating Tesla account |
|
29
|
+
| `password` | String, required | `edisonsux` | The password for the authenticating Tesla account |
|
30
|
+
|
31
|
+
### Request
|
32
|
+
|
33
|
+
```json
|
34
|
+
{
|
35
|
+
"grant_type": "password",
|
36
|
+
"client_id": "abc",
|
37
|
+
"client_secret": "123",
|
38
|
+
"email": "elon@teslamotors.com",
|
39
|
+
"password": "edisonsux"
|
40
|
+
}
|
41
|
+
```
|
28
42
|
|
29
43
|
### Response
|
30
44
|
|
31
45
|
```json
|
32
46
|
{
|
33
|
-
"access_token":"abc123",
|
34
|
-
"token_type":"bearer",
|
47
|
+
"access_token": "abc123",
|
48
|
+
"token_type": "bearer",
|
35
49
|
"expires_in": 3888000,
|
36
|
-
"refresh_token":"cba321",
|
50
|
+
"refresh_token": "cba321",
|
37
51
|
"created_at": 1538359034
|
38
52
|
}
|
39
53
|
```
|
40
54
|
|
55
|
+
## POST `/oauth/token?grant_type=refresh_token`
|
56
|
+
|
57
|
+
You can use the `refresh_token` from the Password Grant to do [an OAuth 2.0 Refresh Token Grant](https://oauth.net/2/grant-types/refresh-token/) and obtain a new access token. Note: This will invalidate the previous access token.
|
58
|
+
|
59
|
+
### Request parameters
|
60
|
+
|
61
|
+
| Field | Type | Example | Description |
|
62
|
+
| :-------------- | :--------------- | :-------------- | :-------------------------------------------------------- |
|
63
|
+
| `grant_type` | String, required | `refresh_token` | The type of OAuth grant. Always "refresh_token" |
|
64
|
+
| `client_id` | String, required | `abc` | The OAuth client ID |
|
65
|
+
| `client_secret` | String, required | `123` | The OAuth client secret |
|
66
|
+
| `refresh_token` | String, required | `cba321` | The refresh token returned from a previous token request. |
|
67
|
+
|
68
|
+
### Request
|
69
|
+
|
70
|
+
```json
|
71
|
+
{
|
72
|
+
"grant_type": "refresh_token",
|
73
|
+
"client_id": "abc",
|
74
|
+
"client_secret": "123",
|
75
|
+
"refresh_token": "cba321"
|
76
|
+
}
|
77
|
+
```
|
78
|
+
|
79
|
+
### Response
|
80
|
+
|
81
|
+
```json
|
82
|
+
{
|
83
|
+
"access_token": "abc123",
|
84
|
+
"token_type": "bearer",
|
85
|
+
"expires_in": 3888000,
|
86
|
+
"refresh_token": "cba321",
|
87
|
+
"created_at": 1538359034
|
88
|
+
}
|
89
|
+
```
|
data/lib/tesla_api/client.rb
CHANGED
data/lib/tesla_api/vehicle.rb
CHANGED
@@ -2,10 +2,11 @@ module TeslaApi
|
|
2
2
|
class Vehicle
|
3
3
|
include Stream
|
4
4
|
include Autopark
|
5
|
-
attr_reader :api, :id, :vehicle
|
5
|
+
attr_reader :api, :email, :id, :vehicle
|
6
6
|
|
7
|
-
def initialize(api, id, vehicle)
|
7
|
+
def initialize(api, email, id, vehicle)
|
8
8
|
@api = api
|
9
|
+
@email = email
|
9
10
|
@id = id
|
10
11
|
@vehicle = vehicle
|
11
12
|
end
|
data/lib/tesla_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tesla_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Dorr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|