my_john_deere_api 0.12.2 → 0.12.3
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/README.md +75 -0
- data/lib/my_john_deere_api/authorize.rb +1 -1
- data/lib/my_john_deere_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3237e5669c2065e7cad92bef10e67a23a92ff1c8ae77dc9d8108034d1e903d5
|
4
|
+
data.tar.gz: 94a533836b5a55c9626640b3bfce071e34b579c9ae3ad9794cab85cf93c6db93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd988f0992634f6b0ed2f22cf68c055e73c78ba1a9f0cbfaeb42f9ad81d8394dccb3271b0ad006951d04236645a3c8b57cec67f72215252e56556f0514eeb277
|
7
|
+
data.tar.gz: 7f5d2d31cb5f13c3cfbbfb5d075ed12e6c634d68b95a82fbba8885bf56fef273ee9e16b239f69bf5a63d20bc2f611df9c68bb9027b42c119136579833b947948
|
data/README.md
CHANGED
@@ -8,4 +8,79 @@ This client allows you to connect the MyJohnDeere API without having to code you
|
|
8
8
|
* Simplifies the oAuth negotiation process
|
9
9
|
* Uses ruby enumerables to handle pagination behind the scenes. Calls like `each`, `map`, etc will fetch new pages of data as needed.
|
10
10
|
|
11
|
+
## Documentation
|
12
|
+
|
13
|
+
We provide RDoc documentation, but here is a helpful guide for getting started. Because the gem name is long, all examples are going
|
14
|
+
to assume this shortcut:
|
15
|
+
|
16
|
+
JD = MyJohnDeereApi
|
17
|
+
|
18
|
+
So that when you see:
|
19
|
+
|
20
|
+
JD::Authorize
|
21
|
+
|
22
|
+
It really means:
|
23
|
+
|
24
|
+
MyJohnDeereApi::Authorize
|
25
|
+
|
26
|
+
|
27
|
+
### Authorizing with John Deere via Auth 1.0
|
28
|
+
|
29
|
+
This is the simplest path to authorization, though your user has to jump through an extra hoop of giving you the verification code:
|
30
|
+
|
31
|
+
# Create an authorize object, using your app's API key and secret. You can
|
32
|
+
# pass an environment (`:live` or `:sandbox`), which default to `:live`.
|
33
|
+
authorize = JD::Authorize.new(API_KEY, API_SECRET, environment: :sandbox)
|
34
|
+
|
35
|
+
# Retrieve a valid authorization url from John Deere, where you can send
|
36
|
+
# your user for authorizing your app to the JD platform.
|
37
|
+
url = authorize.authorize_url
|
38
|
+
|
39
|
+
# Verify the code given to the user during the authorization process, and
|
40
|
+
# turn this into access credentials for your user.
|
41
|
+
authorize.verify(code)
|
42
|
+
|
43
|
+
In reality, you will likely need to re-instantiate the authorize object when the user returns, and that works without issue:
|
44
|
+
|
45
|
+
# Create an authorize object, using your app's API key and secret.
|
46
|
+
authorize = JD::Authorize.new(API_KEY, API_SECRET, environment: :sandbox)
|
47
|
+
|
48
|
+
# Retrieve a valid authorization url from John Deere.
|
49
|
+
url = authorize.authorize_url
|
50
|
+
|
51
|
+
# Queue elevator music while your app serves other users...
|
52
|
+
|
53
|
+
# Re-create the authorize instance in a different process
|
54
|
+
authorize = JD::Authorize.new(API_KEY, API_SECRET, environment: :sandbox)
|
55
|
+
|
56
|
+
# Proceed as normal
|
57
|
+
authorize.verify(code)
|
58
|
+
|
59
|
+
In a web app, you're prefer that your user doesn't have to copy/paste verification codes. So you can pass in an :oauth_callback url.
|
60
|
+
When the user authorizes your app with John Deere, they are redirected to the url you provide, with the paraameter 'oauth_verifier'
|
61
|
+
that contains the verification code so the user doesn't have to provide it.
|
62
|
+
|
63
|
+
# Create an authorize object, using your app's API key and secret.
|
64
|
+
authorize = JD::Authorize.new(
|
65
|
+
API_KEY,
|
66
|
+
API_SECRET,
|
67
|
+
environment: :sandbox,
|
68
|
+
oauth_callback: 'https://example.com'
|
69
|
+
)
|
70
|
+
|
71
|
+
# Retrieve a valid authorization url from John Deere.
|
72
|
+
# This will contain the callback url encoded into the
|
73
|
+
# query string for you.
|
74
|
+
url = authorize.authorize_url
|
75
|
+
|
76
|
+
# Queue elevator music while your app serves other users...
|
77
|
+
|
78
|
+
# Re-create the authorize instance in a different process.
|
79
|
+
# It's not necessary to re-initialize with the callback url.
|
80
|
+
authorize = JD::Authorize.new(API_KEY, API_SECRET, environment: :sandbox)
|
81
|
+
|
82
|
+
# Inside a Rails controller, you might do this:
|
83
|
+
authorize.verify(params[:oauth_verifier])
|
84
|
+
|
85
|
+
|
11
86
|
More details coming soon.
|