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 +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +8 -1
- data/Gemfile.lock +1 -1
- data/README.md +6 -0
- data/lib/office365/rest/token.rb +21 -16
- data/lib/office365/version.rb +1 -1
- data/lib/office365.rb +2 -4
- 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: '09f37ce4e6f4c9db6d9e1f12d1b53508fc7dcd9b5efa204582a7164764905796'
|
4
|
+
data.tar.gz: f5cdfb070ba62cfbd96e81f801e3e2dc8f5584115338ad85c92d9dae86710e6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bb8b810b6aa38e89b2e906e3e7dffcfc63291edd0687dade41f41e7e9a7d3e1ff0f546f5e63ec5339fbe439ed75a06cbc48b11bfc38d8eb7dd45ee4535d6ebb
|
7
|
+
data.tar.gz: 505e05289637208d656904933e93e8123f3fc0355988cc23edbab27830627f24bb894a441ad389405bccbd733cd91641138310c28eb80a54a26695e9ad1511f0
|
data/.rubocop.yml
CHANGED
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
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.
|
data/lib/office365/rest/token.rb
CHANGED
@@ -3,28 +3,33 @@
|
|
3
3
|
module Office365
|
4
4
|
module REST
|
5
5
|
module Token
|
6
|
-
def
|
7
|
-
|
8
|
-
|
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
|
-
|
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
|
-
|
18
|
+
[base_uri, "?", azure_params].join
|
15
19
|
end
|
16
20
|
|
17
|
-
|
21
|
+
def token_url
|
22
|
+
[LOGIN_HOST, "/#{tenant_id}/oauth2/v2.0/token"].join
|
23
|
+
end
|
18
24
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
data/lib/office365/version.rb
CHANGED
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
|