shilpa20 1.2.0 → 1.2.1
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/domain/authentication.rb +7 -4
- data/lib/shilpa20/authentication_service.rb +24 -7
- data/lib/shilpa20.rb +7 -1
- 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: 3f3dadf7fdb26c4c174030b626080b6d6d4864dfb3519a01fae8cb049b68655e
|
4
|
+
data.tar.gz: 7ad7b99f84f17109537bee66e7c0320b331348516ed8b5d37486701288f3098e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52bd2e06400559133f4a040d80bae582f8cd220bdfac44f0a9b5b32cae27991b68d48ec0d63b5a4cf81217f823d4fbe8f0958f14ce0b1536952fb13d8f175e50
|
7
|
+
data.tar.gz: 91a71dddbe786f58e0d082f66696f56fc79f2c8d8416f3a3319474cf96757376c3a9e27e208656e72af4a28b570539f19ce2fd1f542ab847e3d2cced97bb7bc5
|
@@ -5,10 +5,11 @@ class Authentication
|
|
5
5
|
attr_accessor :client_secret
|
6
6
|
attr_accessor :username
|
7
7
|
attr_accessor :password
|
8
|
+
attr_accessor :refresh_token
|
8
9
|
|
9
|
-
def initialize grant_type: nil, client_id: nil, client_secret: nil, username: nil, password: nil
|
10
|
-
self.grant_type, self.client_id, self.client_secret, self.username, self.password =
|
11
|
-
grant_type, client_id, client_secret, username, password
|
10
|
+
def initialize grant_type: nil, client_id: nil, client_secret: nil, username: nil, password: nil, refresh_token:nil
|
11
|
+
self.grant_type, self.client_id, self.client_secret, self.username, self.password, self.refresh_token =
|
12
|
+
grant_type, client_id, client_secret, username, password, refresh_token
|
12
13
|
end
|
13
14
|
|
14
15
|
|
@@ -18,7 +19,8 @@ class Authentication
|
|
18
19
|
client_id: @client_id,
|
19
20
|
client_secret: @client_secret,
|
20
21
|
username: @username,
|
21
|
-
password: @password
|
22
|
+
password: @password,
|
23
|
+
refresh_token: @refresh_token
|
22
24
|
}.to_json(*a)
|
23
25
|
end
|
24
26
|
|
@@ -29,6 +31,7 @@ class Authentication
|
|
29
31
|
b_from_json.client_secret = o['client_secret']
|
30
32
|
b_from_json.username = o['username']
|
31
33
|
b_from_json.password = o['password']
|
34
|
+
b_from_json.refresh_token = o['refresh_token']
|
32
35
|
b_from_json
|
33
36
|
end
|
34
37
|
|
@@ -5,15 +5,23 @@ require_relative '../domain/application_config.rb'
|
|
5
5
|
|
6
6
|
class AuthenticationService
|
7
7
|
@@authentication_url = 'https://showoff-rails-react-production.herokuapp.com/oauth/token'
|
8
|
+
@@client_id = ApplicationConfig.get_client_id
|
9
|
+
@@client_secret = ApplicationConfig.get_client_secret
|
8
10
|
|
9
11
|
def self.create_authentication(auth_data)
|
10
|
-
auth_data
|
11
|
-
auth_data.client_secret = ApplicationConfig.get_client_secret
|
12
|
+
auth_data = get_auth_with_client_info(auth_data)
|
12
13
|
auth_payload = Authentication.get_payload(auth_data)
|
13
14
|
return RestClient::Request.execute(method: :post, url: @@authentication_url,
|
14
15
|
payload: auth_payload, headers: {'Content-Type': 'application/json'})
|
15
16
|
end
|
16
17
|
|
18
|
+
def self.refresh_token(auth_data, bearer_token)
|
19
|
+
auth_data = get_auth_with_client_info(auth_data)
|
20
|
+
auth_payload = Authentication.get_payload(auth_data)
|
21
|
+
return RestClient::Request.execute(method: :post, url: @@authentication_url,
|
22
|
+
payload: auth_payload, headers: {'Content-Type': 'application/json', 'Authorization':'Bearer '+ bearer_token})
|
23
|
+
end
|
24
|
+
|
17
25
|
# to remove once tested
|
18
26
|
def self.create_auth_data
|
19
27
|
auth = Authentication.new
|
@@ -25,12 +33,21 @@ class AuthenticationService
|
|
25
33
|
return auth
|
26
34
|
end
|
27
35
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
36
|
+
|
37
|
+
#def self.refresh_token(refresh_data)
|
38
|
+
# refresh_payload = Authentication.get_payload(refresh_data)
|
39
|
+
# return RestClient::Request.execute(method: :post, url: @@authentication_url,
|
40
|
+
# payload: refresh_payload, headers: {'Content-Type': 'application/json'})
|
41
|
+
#end
|
42
|
+
|
43
|
+
|
44
|
+
def self.get_auth_with_client_info(auth_data)
|
45
|
+
auth_data.client_id = @@client_id
|
46
|
+
auth_data.client_secret = @@client_secret
|
47
|
+
return auth_data
|
48
|
+
end
|
33
49
|
|
50
|
+
#remove once tested
|
34
51
|
def self.get_access_token
|
35
52
|
auth_data = AuthenticationService.create_auth_data
|
36
53
|
authJson = AuthenticationService.create_authentication(auth_data)
|
data/lib/shilpa20.rb
CHANGED
@@ -12,7 +12,7 @@ class Shilpa20
|
|
12
12
|
|
13
13
|
def self.set_config(client_id, client_secret)
|
14
14
|
#ApplicationConfig.set_config("277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe", "d6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352")
|
15
|
-
|
15
|
+
ApplicationConfig.set_config(client_id, client_secret)
|
16
16
|
end
|
17
17
|
|
18
18
|
|
@@ -21,6 +21,11 @@ class Shilpa20
|
|
21
21
|
return AuthenticationService.create_authentication(auth_data)
|
22
22
|
end
|
23
23
|
|
24
|
+
#Create authentication token
|
25
|
+
def self.refresh_token(auth_data, bearer_token)
|
26
|
+
return AuthenticationService.refresh_token(auth_data, bearer_token)
|
27
|
+
end
|
28
|
+
|
24
29
|
#Create user
|
25
30
|
def self.create_user(user_data)
|
26
31
|
return UserService.create_user(user_data)
|
@@ -114,6 +119,7 @@ class Shilpa20
|
|
114
119
|
end
|
115
120
|
|
116
121
|
#puts " Inside shilpa 20"
|
122
|
+
#ApplicationConfig.set_config("277ef29692f9a70d511415dc60592daf4cf2c6f6552d3e1b769924b2f2e2e6fe", "d6106f26e8ff5b749a606a1fba557f44eb3dca8f48596847770beb9b643ea352")
|
117
123
|
#puts Shilpa20.create_authentication_token(AuthenticationService.create_auth_data)
|
118
124
|
#Shilpa20.set_config("cid1","csecret1")
|
119
125
|
#Shilpa20.getConfig
|