fidor_starter_kits 0.3.7 → 0.4.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30fdb6f18b6e5fc63cf4c0fa3c62ae153c937b84
|
4
|
+
data.tar.gz: 824c624eb90dccf800c6d193d8d9258ab6f369d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91857810606f02f9be3e5112e21e8a5420d45a9246ff47bd1fa9e2d0ae2455d07d9fa08894e230af79e892bdb3f0c36a21ccc1c70120f02f7f8a9f54288800e2
|
7
|
+
data.tar.gz: d349653302eb2728b4c867f2458b26f381cb748d8cc7e8eb0bfe747e91a594bfdb893f74e6c510b60d33d60efd153a4289f701164f0c6a90a735f7f6f85201b4
|
@@ -121,6 +121,7 @@ func render(endpoint string, w http.ResponseWriter, r *http.Request) {
|
|
121
121
|
w.Write([]byte(err.Error()))
|
122
122
|
} else {
|
123
123
|
api_req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", accessToken))
|
124
|
+
api_req.Header.Set("Accept", "application/vnd.fidor.de; version=1,text/json")
|
124
125
|
|
125
126
|
client := &http.Client{}
|
126
127
|
if api_resp, err := client.Do(api_req); err != nil {
|
@@ -210,15 +211,18 @@ func retrieveTokenFromCode(code string, target_endpoint string) (token string, e
|
|
210
211
|
// assemble the API endpoint URL and request payload
|
211
212
|
redirect_uri := fmt.Sprintf("%s/oauth?ep=%s", fidorConfig.AppUrl, target_endpoint)
|
212
213
|
tokenPayload := url.Values{
|
213
|
-
"client_id":
|
214
|
-
"client_secret": {fidorConfig.ClientSecret},
|
215
|
-
"code":
|
216
|
-
"redirect_uri":
|
217
|
-
"grant_type":
|
214
|
+
"client_id": {fidorConfig.ClientId},
|
215
|
+
//"client_secret": {fidorConfig.ClientSecret},
|
216
|
+
"code": {code},
|
217
|
+
"redirect_uri": {url.QueryEscape(redirect_uri)},
|
218
|
+
"grant_type": {"authorization_code"},
|
218
219
|
}
|
219
220
|
// Call the Oauth `token` endpoint
|
220
221
|
tokenUrl := fmt.Sprintf("%s/token", fidorConfig.FidorOauthUrl)
|
221
|
-
|
222
|
+
req, _ := http.NewRequest("POST", tokenUrl, strings.NewReader(tokenPayload.Encode()))
|
223
|
+
req.SetBasicAuth(fidorConfig.ClientId, fidorConfig.ClientSecret)
|
224
|
+
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
225
|
+
if resp, err := http.DefaultClient.Do(req); err != nil {
|
222
226
|
println(err)
|
223
227
|
return "", err
|
224
228
|
} else {
|
@@ -77,7 +77,8 @@ function retrieve_access_token_from_code( code, target_endpoint, cb ) {
|
|
77
77
|
method: "POST",
|
78
78
|
path : oauth_url.path+"/token",
|
79
79
|
port : oauth_url.port,
|
80
|
-
host : oauth_url.hostname
|
80
|
+
host : oauth_url.hostname,
|
81
|
+
auth : fidor_config.client_id+":"+fidor_config.client_secret
|
81
82
|
}
|
82
83
|
|
83
84
|
// ... what to send
|
@@ -85,7 +86,7 @@ function retrieve_access_token_from_code( code, target_endpoint, cb ) {
|
|
85
86
|
var postData = {
|
86
87
|
code : code,
|
87
88
|
client_id : fidor_config.client_id,
|
88
|
-
client_secret : fidor_config.client_secret,
|
89
|
+
// client_secret : fidor_config.client_secret, // deprecated, please use basic auth, see. postOptions, above
|
89
90
|
redirect_uri : encodeURIComponent(redirect_uri),
|
90
91
|
grant_type : "authorization_code"
|
91
92
|
}
|
@@ -205,7 +206,8 @@ function render (endpoint, req, res) {
|
|
205
206
|
port: api_endpoint.port,
|
206
207
|
method: "GET",
|
207
208
|
headers: {
|
208
|
-
"Authorization": "Bearer "+access_token
|
209
|
+
"Authorization": "Bearer "+access_token,
|
210
|
+
"Accept": "application/vnd.fidor.de; version=1,text/json"
|
209
211
|
}
|
210
212
|
}
|
211
213
|
|
@@ -21,13 +21,15 @@ get '/' do
|
|
21
21
|
post_params = { client_id: @client_id,
|
22
22
|
redirect_uri: CGI::escape(@app_url),
|
23
23
|
code: code,
|
24
|
-
client_secret: @client_secret,
|
24
|
+
#client_secret: @client_secret,
|
25
25
|
grant_type: 'authorization_code' }
|
26
|
-
|
26
|
+
auth = {:username => @client_id, :password => @client_secret}
|
27
|
+
resp = HTTParty.post(token_url, body: post_params, basic_auth: auth )
|
27
28
|
|
28
29
|
# GET current user setting the access-token in the request header
|
29
30
|
user = HTTParty.get( "#{@fidor_api_url}/users/current",
|
30
|
-
headers: { 'Authorization' => "Bearer #{resp['access_token']}"
|
31
|
+
headers: { 'Authorization' => "Bearer #{resp['access_token']}",
|
32
|
+
'Accept' => "application/vnd.fidor.de; version=1,text/json"} )
|
31
33
|
|
32
34
|
"<h2>Hello #{user['email']}</h2>
|
33
35
|
<i>May i present the access token response:</i>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fidor_starter_kits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Georg Leciejewski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|