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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/arcgis_vrps/auth.rb +22 -6
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c55d023e8a8b717c14e7c60c6499a20943c8cfb4
4
- data.tar.gz: 65df52140b54b1638b4962590296fe7b681a6009
3
+ metadata.gz: 72d54afc33a9f7db6fb35983e0ba6ed36320d87c
4
+ data.tar.gz: 2e033563b93c0a928e1e01eaa2f62d9dd794cab9
5
5
  SHA512:
6
- metadata.gz: 44d800f1d692f80d1349835c92688c54b619a38ae955ef602fb88fdcb21de4c07e70adb96bbbd33def299a45ba5f14b7af8b77f66a6a492596fa7afb6012312a
7
- data.tar.gz: b3a7b37e27778657abb2ec35ec669e4e5d9ffd5aeec0c9828d4ff0c7982f3351b62054e842f3cd6f8eb42a9c53fb3f305d1c424bee9b1d14eb69a2cd2b48e1b9
6
+ metadata.gz: a5eca0365ec0252c043bae00f78b5a2bd4341baf24cdbad6c6b0ab94b710f132c0e0c9ca49104434531caf1f261f4e0c6bcb703d26fa92528f3066301abe91be
7
+ data.tar.gz: 47b86e2c28ff290256ccc687a8e56fc743e9e3fca2abc819f33129e12e050b379c1a6843fdb079a5fc1b92d5bfab17af46d2bad069af90463a98132d3b6b6aa9
@@ -13,12 +13,28 @@ class Auth
13
13
 
14
14
  def generateToken
15
15
  begin
16
- res = Net::HTTP.post_form URI('https://www.arcgis.com/sharing/rest/oauth2/token'),
17
- f: 'json',
18
- client_id: @client_id,
19
- client_secret: @client_secret,
20
- grant_type: 'client_credentials'
21
- res.use_ssl = true
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arcgis_vrps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.8
4
+ version: 0.0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kiong