tesla_api 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b31e0c77b2bb1e672152be73a92a86c32ad21ed1c00ac90d4c1710d2b631b9c
4
- data.tar.gz: d7cd8c5bbbfa5594c36449055f04ca915c2608a8974f2b9945a241d7a3603240
3
+ metadata.gz: f11d922517791fd73cf99ac8ce3a350191ffb377995dedb2282427a5f97d668d
4
+ data.tar.gz: ff687a34dc10b5372a9746d4686915b5209d0fb6b6ce68fcb10da0ba4314d68e
5
5
  SHA512:
6
- metadata.gz: 1d0bff41652367d606b9e6e2d16865a4636a6f313ce5f50f9efb65e46edc72ecca2f7c1adc210f4af6ab716e25706db1e14af65c057de4358c2aec1da07b2493
7
- data.tar.gz: d0d9450777a37d1800d4d30238c89eb2b7075dd49a22760204c341146cb287cfcda9401a68c8f27b749c5c5496c263b7bc5c7b48721c88d7d042c2bfc337ee4f
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
- The 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.
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
- ## POST `/oauth/token`
19
+ The access token has a 45 day expiration.
18
20
 
19
21
  ### Request parameters
20
22
 
21
- | Field | Type | Example | Description |
22
- | :--- | :--- | :--- | :--- |
23
- | `grant_type` | String, required | `password` | The type of OAuth grant. Always "password" |
24
- | `client_id` | String, required | `abc` | The OAuth client ID |
25
- | `client_secret` | String, required | `123` | The OAuth client secret |
26
- | `email` | String, required | `elon@teslamotors.com` | The email for the authenticating Tesla account |
27
- | `password` | String, required | `edisonsux` | The password for the authenticating Tesla account |
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
+ ```
@@ -54,7 +54,7 @@ module TeslaApi
54
54
  end
55
55
 
56
56
  def vehicles
57
- self.class.get('/vehicles')['response'].map { |v| Vehicle.new(self.class, v['id'], v) }
57
+ self.class.get('/vehicles')['response'].map { |v| Vehicle.new(self.class, email, v['id'], v) }
58
58
  end
59
59
  end
60
60
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module TeslaApi
2
- VERSION = '1.4.0'
2
+ VERSION = '1.4.1'
3
3
  end
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.0
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 00:00:00.000000000 Z
11
+ date: 2018-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty