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: 714384718ce26e4cc8ab8768f8e0ea3e83c75052
4
- data.tar.gz: d7d856ad3b65c284c40eff20352ea90f56d48629
3
+ metadata.gz: 30fdb6f18b6e5fc63cf4c0fa3c62ae153c937b84
4
+ data.tar.gz: 824c624eb90dccf800c6d193d8d9258ab6f369d5
5
5
  SHA512:
6
- metadata.gz: 9150c839dad0cbef014ceb05570ed302605108875399c9f8c335f0404859b8dbb0f01ad26eedd9eb8192088490ee28d2e60867d4de7c97067ff3132960cad3f1
7
- data.tar.gz: fa9162749d414caeb0f4dcf324c0309a46cb057ae2d26e3444ee3602ea2bae140471d7474e96ea83261a463fd595bf9c39f2a79014110d0c85933e35b6cba1d6
6
+ metadata.gz: 91857810606f02f9be3e5112e21e8a5420d45a9246ff47bd1fa9e2d0ae2455d07d9fa08894e230af79e892bdb3f0c36a21ccc1c70120f02f7f8a9f54288800e2
7
+ data.tar.gz: d349653302eb2728b4c867f2458b26f381cb748d8cc7e8eb0bfe747e91a594bfdb893f74e6c510b60d33d60efd153a4289f701164f0c6a90a735f7f6f85201b4
@@ -1,3 +1,3 @@
1
1
  module FidorStarterKits
2
- VERSION = '0.3.7'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -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": {fidorConfig.ClientId},
214
- "client_secret": {fidorConfig.ClientSecret},
215
- "code": {code},
216
- "redirect_uri": {url.QueryEscape(redirect_uri)},
217
- "grant_type": {"authorization_code"},
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
- if resp, err := http.PostForm(tokenUrl, tokenPayload); err != nil {
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
- resp = HTTParty.post(token_url, body: post_params )
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.3.7
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-07-07 00:00:00.000000000 Z
11
+ date: 2015-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip