ruby-office365 0.1.3 → 0.1.4

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: d2c2997d3d775d3450dd11a6774e3edee59fc22b307b85b7d525ac561cd19eeb
4
- data.tar.gz: 02bf02e037717417d889e4a81bbead7ead87210390adfb57f9d1643d851b905e
3
+ metadata.gz: '09f37ce4e6f4c9db6d9e1f12d1b53508fc7dcd9b5efa204582a7164764905796'
4
+ data.tar.gz: f5cdfb070ba62cfbd96e81f801e3e2dc8f5584115338ad85c92d9dae86710e6b
5
5
  SHA512:
6
- metadata.gz: e33d6e7f5d01292a86ecfd6dd70b432f8d4ed88cccdc427a2c09a0c9506610242444a1f49bf48f1c95a306213c7d11d995af5dabcb0fc76073749ea8d0aca14a
7
- data.tar.gz: 707cd85b26cf08352590ae658cc76f981b0cca8a8c3ded186d44cc712e4ee334bf6ef59bc89ac5097f33441e4ea4c49f7f306dcd51d87d300832650fe25bdeb2
6
+ metadata.gz: 8bb8b810b6aa38e89b2e906e3e7dffcfc63291edd0687dade41f41e7e9a7d3e1ff0f546f5e63ec5339fbe439ed75a06cbc48b11bfc38d8eb7dd45ee4535d6ebb
7
+ data.tar.gz: 505e05289637208d656904933e93e8123f3fc0355988cc23edbab27830627f24bb894a441ad389405bccbd733cd91641138310c28eb80a54a26695e9ad1511f0
data/.rubocop.yml CHANGED
@@ -20,3 +20,6 @@ Style/Documentation:
20
20
 
21
21
  Metrics/BlockLength:
22
22
  Max: 150
23
+
24
+ Metrics/MethodLength:
25
+ Max: 50
data/CHANGELOG.md CHANGED
@@ -21,4 +21,11 @@
21
21
 
22
22
  - Integrate REST API to get contacts
23
23
  - get profile `client.contacts`
24
- - get contacts data with next link `client.contacts({next_link: 'xxx'})`
24
+ - get contacts data with next link `client.contacts({next_link: 'xxx'})`
25
+
26
+ ## [0.1.4] - (2022-10-26)
27
+
28
+ - Generate URLs for token and able to refresh token
29
+ - get authorize URL `client.authorize_url`
30
+ - get token URL `client.token_url`
31
+ - be able to refresh token `client.refresh_token!`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-office365 (0.1.3)
4
+ ruby-office365 (0.1.4)
5
5
  faraday
6
6
  faraday_middleware
7
7
 
data/README.md CHANGED
@@ -132,6 +132,12 @@ irb(main):018:0> response[:results][0].as_json
132
132
  }
133
133
  ```
134
134
 
135
+ **Refresh User Token**
136
+
137
+ ```ruby
138
+ irb(main):005:0> client.refresh_token!
139
+ ```
140
+
135
141
  ## Copyright
136
142
 
137
143
  Copyright (c) 2022 Encore Shao. See LICENSE for details.
@@ -3,28 +3,33 @@
3
3
  module Office365
4
4
  module REST
5
5
  module Token
6
- def token_refresh
7
- args = {
8
- refresh_token: refresh_token,
6
+ def authorize_url
7
+ base_uri = [LOGIN_HOST, "/#{tenant_id}/oauth2/v2.0/authorize"].join
8
+ azure_params = {
9
9
  client_id: client_id,
10
10
  client_secret: client_secret,
11
- grant_type: "refresh_token"
12
- }
11
+ scope: Office365::SCOPE,
12
+ response_type: "code",
13
+ response_mode: "query",
14
+ redirect_uri: redirect_uri,
15
+ state: SecureRandom.hex
16
+ }.to_query
13
17
 
14
- post(oauth_client.token_url, args)
18
+ [base_uri, "?", azure_params].join
15
19
  end
16
20
 
17
- private
21
+ def token_url
22
+ [LOGIN_HOST, "/#{tenant_id}/oauth2/v2.0/token"].join
23
+ end
18
24
 
19
- def oauth_client
20
- @oauth_client ||= OAuth2::Client.new(
21
- client_id,
22
- client_secret,
23
- authorize_url: AUTHORIZE_URL,
24
- site: LOGIN_HOST,
25
- token_url: TOKEN_URL,
26
- redirect_uri: redirect_uri
27
- )
25
+ def refresh_token!
26
+ post(token_url, {
27
+ refresh_token: refresh_token,
28
+ client_id: client_id,
29
+ client_secret: client_secret,
30
+ grant_type: "refresh_token",
31
+ scope: Office365::SCOPE
32
+ })
28
33
  end
29
34
  end
30
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Office365
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
data/lib/office365.rb CHANGED
@@ -9,11 +9,9 @@ require "office365/models"
9
9
 
10
10
  module Office365
11
11
  API_HOST = "https://graph.microsoft.com"
12
- LOGIN_HOST = "https://login.microsoftonline.com/"
13
-
14
- AUTHORIZE_URL = "common/oauth2/authorize"
15
- TOKEN_URL = "common/oauth2/token"
16
12
  API_VERSION = "v1.0"
13
+
14
+ LOGIN_HOST = "https://login.microsoftonline.com"
17
15
  SCOPE = "User.read Calendars.read Mail.ReadBasic Contacts.Read"
18
16
 
19
17
  class Error < StandardError; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-office365
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Encore Shao