boxr 0.27.0 → 0.28.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93e44fc598ab6789018d63eaf7277ab1cd616138
4
- data.tar.gz: a7bf8e2e7e8043ec2c48c818e3a2e4396de14816
3
+ metadata.gz: b15e90705ae77e54c7e29b60d798f78fb2f43df2
4
+ data.tar.gz: 88b53548306c6f9aecc6521f3392fe16bcfb3ce8
5
5
  SHA512:
6
- metadata.gz: a23f74f3d18e47d704bc08f0ec9fa5d59d6d0ef245bac16bad986759915f51f28a834e7b2e2e06ca76986971e4c6225567a7b7c8ea05ff39eb2d9ace82e41585
7
- data.tar.gz: 9356cbc841b364d9451652d9c609b6b2b428ab9c8da8f31aed3a6a3d3e17505129f1d8c15e96e999c131629a3077b80f6bf4f2d1263a8335c88d0333a0905748
6
+ metadata.gz: 3bb9d947f065884e1647534bab48dd7a1127d3262e55f339982fef9d4eaef930fc1f57c85436543ddbc76a63528fcf989a2ae7f350188381b6ce3b93f355a383
7
+ data.tar.gz: a2eb5cbc5cefb115f3f5db3b39ea7654391f4a6beb3e193b5dc3a92cf5b74728bb9e51e85a3b86e93cd904e4418be8ac63203445b2547cefce563039330d8740
data/README.md CHANGED
@@ -116,9 +116,9 @@ Boxr::refresh_tokens(refresh_token, client_id: ENV['BOX_CLIENT_ID'], client_secr
116
116
  Boxr::revoke_tokens(token, client_id: ENV['BOX_CLIENT_ID'], client_secret: ENV['BOX_CLIENT_SECRET'])
117
117
 
118
118
  #JWT methods
119
- Boxr::get_enterprise_token(private_key: ENV['JWT_PRIVATE_KEY'], private_key_password: ENV['JWT_PRIVATE_KEY_PASSWORD'], enterprise_id: ENV['BOX_ENTERPRISE_ID'], client_id: ENV['BOX_CLIENT_ID'])
119
+ Boxr::get_enterprise_token(private_key: ENV['JWT_PRIVATE_KEY'], private_key_password: ENV['JWT_PRIVATE_KEY_PASSWORD'], enterprise_id: ENV['BOX_ENTERPRISE_ID'], client_id: ENV['BOX_CLIENT_ID'], client_secret: ENV['BOX_CLIENT_SECRET'])
120
120
 
121
- Boxr::get_user_token(user_id, private_key: ENV['JWT_PRIVATE_KEY'], private_key_password: ENV['JWT_PRIVATE_KEY_PASSWORD'], client_id: ENV['BOX_CLIENT_ID'])
121
+ Boxr::get_user_token(user_id, private_key: ENV['JWT_PRIVATE_KEY'], private_key_password: ENV['JWT_PRIVATE_KEY_PASSWORD'], client_id: ENV['BOX_CLIENT_ID'], client_secret: ENV['BOX_CLIENT_SECRET'])
122
122
  ```
123
123
  #### [Folders](https://developers.box.com/docs/#folders)
124
124
  ```ruby
@@ -4,9 +4,9 @@ require 'awesome_print'
4
4
  require 'openssl'
5
5
 
6
6
 
7
- private_key = OpenSSL::PKey::RSA.new(File.read(ENV['JWT_SECRET_KEY_PATH']), ENV['JWT_SECRET_KEY_PASSWORD'])
7
+ private_key = OpenSSL::PKey::RSA.new(File.read(ENV['JWT_PRIVATE_KEY_PATH']), ENV['JWT_PRIVATE_KEY_PASSWORD'])
8
8
 
9
9
  #make sure ENV['BOX_ENTERPRISE_ID'] and ENV['BOX_CLIENT_ID'] are set
10
- response = Boxr::get_enterprise_token(private_key)
10
+ response = Boxr::get_enterprise_token(private_key: private_key)
11
11
 
12
12
  ap response
@@ -25,15 +25,17 @@ module Boxr
25
25
  end
26
26
 
27
27
  def self.get_enterprise_token(private_key: ENV['JWT_PRIVATE_KEY'], private_key_password: ENV['JWT_PRIVATE_KEY_PASSWORD'],
28
- enterprise_id: ENV['BOX_ENTERPRISE_ID'], client_id: ENV['BOX_CLIENT_ID'])
28
+ enterprise_id: ENV['BOX_ENTERPRISE_ID'], client_id: ENV['BOX_CLIENT_ID'], client_secret: ENV['BOX_CLIENT_SECRET'])
29
29
  unlocked_private_key = unlock_key(private_key, private_key_password)
30
- jwt_auth_post(unlocked_private_key, client_id, enterprise_id, "enterprise")
30
+ assertion = jwt_assertion(unlocked_private_key, client_id, enterprise_id, "enterprise")
31
+ get_token(grant_type: JWT_GRANT_TYPE, assertion: assertion, client_id: client_id, client_secret: client_secret)
31
32
  end
32
33
 
33
34
  def self.get_user_token(user_id, private_key: ENV['JWT_PRIVATE_KEY'], private_key_password: ENV['JWT_PRIVATE_KEY_PASSWORD'],
34
- client_id: ENV['BOX_CLIENT_ID'])
35
+ client_id: ENV['BOX_CLIENT_ID'], client_secret: ENV['BOX_CLIENT_SECRET'])
35
36
  unlocked_private_key = unlock_key(private_key, private_key_password)
36
- jwt_auth_post(unlocked_private_key, client_id, user_id, "user")
37
+ assertion = jwt_assertion(unlocked_private_key, client_id, user_id, "user")
38
+ get_token(grant_type: JWT_GRANT_TYPE, assertion: assertion, client_id: client_id, client_secret: client_secret)
37
39
  end
38
40
 
39
41
  def self.refresh_tokens(refresh_token, client_id: ENV['BOX_CLIENT_ID'], client_secret: ENV['BOX_CLIENT_SECRET'])
@@ -59,7 +61,7 @@ module Boxr
59
61
  private
60
62
 
61
63
 
62
- def self.jwt_auth_post(private_key, iss, sub, box_sub_type)
64
+ def self.jwt_assertion(private_key, iss, sub, box_sub_type)
63
65
  payload = {
64
66
  iss: iss,
65
67
  sub: sub,
@@ -68,9 +70,8 @@ module Boxr
68
70
  jti: SecureRandom.hex(64),
69
71
  exp: (Time.now.utc + 10).to_i
70
72
  }
71
- assertion = JWT.encode(payload, private_key, "RS256")
72
-
73
- get_token(grant_type: JWT_GRANT_TYPE, assertion: assertion)
73
+
74
+ JWT.encode(payload, private_key, "RS256")
74
75
  end
75
76
 
76
77
  def self.auth_post(uri, body)
@@ -1,3 +1,3 @@
1
1
  module Boxr
2
- VERSION = "0.27.0"
2
+ VERSION = "0.28.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.0
4
+ version: 0.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Burnette
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-04 00:00:00.000000000 Z
11
+ date: 2015-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler