arcgis_vrps 0.0.2.8 → 0.0.2.9
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/lib/arcgis_vrps/auth.rb +22 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72d54afc33a9f7db6fb35983e0ba6ed36320d87c
|
4
|
+
data.tar.gz: 2e033563b93c0a928e1e01eaa2f62d9dd794cab9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5eca0365ec0252c043bae00f78b5a2bd4341baf24cdbad6c6b0ab94b710f132c0e0c9ca49104434531caf1f261f4e0c6bcb703d26fa92528f3066301abe91be
|
7
|
+
data.tar.gz: 47b86e2c28ff290256ccc687a8e56fc743e9e3fca2abc819f33129e12e050b379c1a6843fdb079a5fc1b92d5bfab17af46d2bad069af90463a98132d3b6b6aa9
|
data/lib/arcgis_vrps/auth.rb
CHANGED
@@ -13,12 +13,28 @@ class Auth
|
|
13
13
|
|
14
14
|
def generateToken
|
15
15
|
begin
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
|
17
|
+
url = "https://www.arcgis.com/sharing/rest/oauth2/token"
|
18
|
+
escaped_url = URI.encode(url)
|
19
|
+
uri = URI.parse(escaped_url)
|
20
|
+
req = Net::HTTP::Post.new(uri.to_s, nil)
|
21
|
+
|
22
|
+
# Expiration is set to 20160 minutes = 2 weeks
|
23
|
+
req.set_form_data(
|
24
|
+
f: 'json',
|
25
|
+
client_id: @client_id,
|
26
|
+
client_secret: @client_secret,
|
27
|
+
grant_type: 'client_credentials'
|
28
|
+
expiration: 20160
|
29
|
+
)
|
30
|
+
|
31
|
+
req.use_ssl = true
|
32
|
+
|
33
|
+
// Invoke API and store response in res
|
34
|
+
res = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
35
|
+
http.request(req)
|
36
|
+
end
|
37
|
+
|
22
38
|
token = JSON.parse(res.body)['access_token']
|
23
39
|
puts "\n"+res.body
|
24
40
|
return token
|