unoffical-omniauth-strava 0.1.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.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.ruby-version +1 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +41 -0
  7. data/Rakefile +6 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +7 -0
  10. data/example/.ruby-version +1 -0
  11. data/example/Gemfile +5 -0
  12. data/example/Gemfile.lock +59 -0
  13. data/example/app.rb +42 -0
  14. data/example/config.ru +11 -0
  15. data/example/memo.md +206 -0
  16. data/example/public/css/style.css +0 -0
  17. data/example/public/vendor/bootstrap/css/bootstrap-theme.css +587 -0
  18. data/example/public/vendor/bootstrap/css/bootstrap-theme.css.map +1 -0
  19. data/example/public/vendor/bootstrap/css/bootstrap-theme.min.css +6 -0
  20. data/example/public/vendor/bootstrap/css/bootstrap-theme.min.css.map +1 -0
  21. data/example/public/vendor/bootstrap/css/bootstrap.css +6760 -0
  22. data/example/public/vendor/bootstrap/css/bootstrap.css.map +1 -0
  23. data/example/public/vendor/bootstrap/css/bootstrap.min.css +35 -0
  24. data/example/public/vendor/bootstrap/css/bootstrap.min.css.map +1 -0
  25. data/example/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
  26. data/example/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.svg +229 -0
  27. data/example/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
  28. data/example/public/vendor/bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
  29. data/example/public/vendor/bootstrap/js/bootstrap.js +1951 -0
  30. data/example/public/vendor/bootstrap/js/bootstrap.min.js +6 -0
  31. data/example/public/vendor/jquery-1.9.1.min.js +5 -0
  32. data/example/views/home.erb +24 -0
  33. data/example/views/layout.erb +25 -0
  34. data/lib/omniauth-strava.rb +7 -0
  35. data/lib/omniauth/strategies/strava.rb +187 -0
  36. data/lib/omniauth/strava.rb +8 -0
  37. data/lib/omniauth/strava/signed_request.rb +52 -0
  38. data/lib/omniauth/strava/version.rb +5 -0
  39. data/omniauth-strava.gemspec +28 -0
  40. metadata +139 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5ff836c9c961e01f814510ef36fe21c8c927205a
4
+ data.tar.gz: ce76ba1f2e3809a86636f164b1d6ac314fafb027
5
+ SHA512:
6
+ metadata.gz: 63b7112950b356d13118b5d8d738c2906250482f05ee0cd9f5755342e620604eba7c3b53e2f99ff7aca9b4e3f672dbba0184409ff14c9c11dbafef839b7b40d4
7
+ data.tar.gz: 291cd237bbe480cff1daec087cabb7369366adae1c9c03dfe212609664540e377a1b63f2166a9d2f5a958a05e5243b5f0e1ef0129ccab9007e20e401fabff6c5
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ .bundle
3
+ .rspec
4
+ /Gemfile.lock
5
+ pkg/*
6
+ .powenv
7
+ tmp
8
+ bin
9
+ example/app.log
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.5
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-strava.gemspec
4
+ gemspec
5
+
6
+ platforms :ruby_18 do
7
+ gem 'hashie', '~> 2.0.5'
8
+ end
9
+
10
+ platforms :rbx do
11
+ gem 'rubysl', '~> 2.0'
12
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Xiang, Zhuyuan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Omniauth::Strava
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/omniauth/strava`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'omniauth-strava'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install omniauth-strava
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/omniauth-strava. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "omniauth/strava"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1 @@
1
+ 2.1.5
data/example/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'sinatra'
4
+ gem 'sinatra-reloader'
5
+ gem 'omniauth-strava', :path => '../'
@@ -0,0 +1,59 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ omniauth-strava (0.1.0)
5
+ omniauth-oauth2 (~> 1.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ backports (3.6.8)
11
+ faraday (0.9.2)
12
+ multipart-post (>= 1.2, < 3)
13
+ hashie (3.4.4)
14
+ jwt (1.5.1)
15
+ multi_json (1.12.1)
16
+ multi_xml (0.5.5)
17
+ multipart-post (2.0.0)
18
+ oauth2 (1.1.0)
19
+ faraday (>= 0.8, < 0.10)
20
+ jwt (~> 1.0, < 1.5.2)
21
+ multi_json (~> 1.3)
22
+ multi_xml (~> 0.5)
23
+ rack (>= 1.2, < 3)
24
+ omniauth (1.3.1)
25
+ hashie (>= 1.2, < 4)
26
+ rack (>= 1.0, < 3)
27
+ omniauth-oauth2 (1.4.0)
28
+ oauth2 (~> 1.0)
29
+ omniauth (~> 1.2)
30
+ rack (1.6.4)
31
+ rack-protection (1.5.3)
32
+ rack
33
+ rack-test (0.6.3)
34
+ rack (>= 1.0)
35
+ sinatra (1.4.7)
36
+ rack (~> 1.5)
37
+ rack-protection (~> 1.4)
38
+ tilt (>= 1.3, < 3)
39
+ sinatra-contrib (1.4.7)
40
+ backports (>= 2.0)
41
+ multi_json
42
+ rack-protection
43
+ rack-test
44
+ sinatra (~> 1.4.0)
45
+ tilt (>= 1.3, < 3)
46
+ sinatra-reloader (1.0)
47
+ sinatra-contrib
48
+ tilt (2.0.5)
49
+
50
+ PLATFORMS
51
+ ruby
52
+
53
+ DEPENDENCIES
54
+ omniauth-strava!
55
+ sinatra
56
+ sinatra-reloader
57
+
58
+ BUNDLED WITH
59
+ 1.10.5
data/example/app.rb ADDED
@@ -0,0 +1,42 @@
1
+ require 'sinatra'
2
+ require "sinatra/reloader"
3
+ require 'yaml'
4
+
5
+ # configure sinatra
6
+ set :run, false
7
+ set :raise_errors, true
8
+
9
+ # setup logging to file
10
+ log = File.new("app.log", "a+")
11
+ $stdout.reopen(log)
12
+ $stderr.reopen(log)
13
+ $stderr.sync = true
14
+ $stdout.sync = true
15
+
16
+ # server-side flow
17
+ get '/' do
18
+ redirect '/auth/strava'
19
+ end
20
+
21
+ get 'auth/:provider' do
22
+
23
+ end
24
+
25
+ get '/auth/:provider/callback' do
26
+ content_type 'text/html'
27
+ @result = MultiJson.encode(request.env['omniauth.auth'])
28
+ session['current_user'] = @result
29
+ redirect '/home'
30
+ end
31
+
32
+
33
+ get '/home' do
34
+ @result = session['current_user']
35
+
36
+ erb :home
37
+ end
38
+
39
+ get '/auth/failure' do
40
+ content_type 'application/json'
41
+ MultiJson.encode(request.env)
42
+ end
data/example/config.ru ADDED
@@ -0,0 +1,11 @@
1
+ require 'bundler/setup'
2
+ require 'omniauth-strava'
3
+ require './app.rb'
4
+
5
+ use Rack::Session::Cookie, :secret => 'abc123'
6
+
7
+ use OmniAuth::Builder do
8
+ provider :strava, ENV['APP_ID'], ENV['APP_SECRET'], :scope => 'public'
9
+ end
10
+
11
+ run Sinatra::Application
data/example/memo.md ADDED
@@ -0,0 +1,206 @@
1
+ --- !ruby/object:OAuth2::Response
2
+ response: &1 !ruby/object:Faraday::Response
3
+ on_complete_callbacks: []
4
+ env: !ruby/struct:Faraday::Env
5
+ method: :post
6
+ body: '{"access_token":"d6d3c5bab1694c4c8412294d529d523ab43a7059","token_type":"Bearer","athlete":{"id":558333,"username":"mathewxiang","resource_state":3,"firstname":"matt","lastname":"xiang","city":"Tokyo,
7
+ Japan","state":"Tokyo","country":"Japan","sex":"M","premium":true,"created_at":"2012-05-27T06:22:17Z","updated_at":"2016-06-19T00:22:41Z","badge_type_id":1,"profile_medium":"https://dgalywyr863hv.cloudfront.net/pictures/athletes/558333/3176446/3/medium.jpg","profile":"https://dgalywyr863hv.cloudfront.net/pictures/athletes/558333/3176446/3/large.jpg","friend":null,"follower":null,"follower_count":11,"friend_count":55,"mutual_friend_count":0,"athlete_type":0,"date_preference":"%m/%d/%Y","measurement_preference":"meters","email":"xiangzhuyuan@gmail.com","ftp":null,"weight":75.0,"clubs":[{"id":134155,"resource_state":2,"name":"Paris-Brest-Paris
8
+ Randonneur 2015","profile_medium":"https://dgalywyr863hv.cloudfront.net/pictures/clubs/134155/2669527/2/medium.jpg","profile":"https://dgalywyr863hv.cloudfront.net/pictures/clubs/134155/2669527/2/large.jpg","cover_photo":null,"cover_photo_small":null,"sport_type":"cycling","member_count":759,"featured":false,"url":"parisbrest"}],"bikes":[{"id":"b2338068","primary":true,"name":"giant
9
+ 1","resource_state":2,"distance":2231038.0}],"shoes":[{"id":"g1265409","primary":true,"name":"Nike
10
+ Flyknit Max","resource_state":2,"distance":211435.0}]}}'
11
+ url: !ruby/object:URI::HTTPS
12
+ scheme: https
13
+ user:
14
+ password:
15
+ host: www.strava.com
16
+ port: 443
17
+ path: "/oauth/token"
18
+ query:
19
+ opaque:
20
+ registry:
21
+ fragment:
22
+ parser:
23
+ request: !ruby/struct:Faraday::RequestOptions
24
+ params_encoder:
25
+ proxy:
26
+ bind:
27
+ timeout:
28
+ open_timeout:
29
+ boundary:
30
+ oauth:
31
+ request_headers: !ruby/hash:Faraday::Utils::Headers
32
+ User-Agent: Faraday v0.9.2
33
+ Content-Type: application/x-www-form-urlencoded
34
+ ssl: !ruby/struct:Faraday::SSLOptions
35
+ verify: true
36
+ ca_file:
37
+ ca_path:
38
+ verify_mode:
39
+ cert_store:
40
+ client_cert:
41
+ client_key:
42
+ certificate:
43
+ private_key:
44
+ verify_depth:
45
+ version:
46
+ symbolized_key_set: !ruby/object:Set
47
+ hash: {}
48
+ parallel_manager:
49
+ params:
50
+ response: *1
51
+ response_headers: !ruby/hash:Faraday::Utils::Headers
52
+ cache-control: max-age=0, private, must-revalidate
53
+ content-type: application/json; charset=UTF-8
54
+ date: Thu, 23 Jun 2016 11:31:00 GMT
55
+ etag: W/"729535ee700cd7043f2317ce3a59a482"
56
+ set-cookie: _strava3_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFVEkiJWQ5OWJlYTlmOTA2ZTZhZjQ1OThkMDJhZmE2NjBjMzAyBjsAVEkiEGNsZWFyX2NsaWNrBjsARlQ%3D--39421d263b11ac7a18b4b49e8f0f7bf101f3b746;
57
+ domain=strava.com; path=/; HttpOnly
58
+ status: 200 OK
59
+ x-frame-options: DENY
60
+ x-request-id: f7df1b8b5eee312b85d3934923a47ab3
61
+ x-ua-compatible: IE=Edge,chrome=1
62
+ content-length: '673'
63
+ connection: Close
64
+ status: 200
65
+ options:
66
+ :parse: :query
67
+
68
+
69
+
70
+ ####access_token a
71
+
72
+
73
+ ```
74
+
75
+ --- !ruby/object:OAuth2::AccessToken
76
+ client: &1 !ruby/object:OAuth2::Client
77
+ id: '12159'
78
+ secret: b48b5dbd9351f67b063708fe24989f0032cbc453
79
+ site: https://www.strava.com
80
+ options:
81
+ :authorize_url: https://www.strava.com/oauth/authorize
82
+ :token_url: oauth/token
83
+ :token_method: :post
84
+ :connection_opts: {}
85
+ :connection_build:
86
+ :max_redirects: 5
87
+ :raise_errors: true
88
+ auth_code: !ruby/object:OAuth2::Strategy::AuthCode
89
+ client: *1
90
+ connection: !ruby/object:Faraday::Connection
91
+ parallel_manager:
92
+ headers: !ruby/hash:Faraday::Utils::Headers
93
+ User-Agent: Faraday v0.9.2
94
+ params: !ruby/hash:Faraday::Utils::ParamsHash {}
95
+ options: !ruby/struct:Faraday::RequestOptions
96
+ params_encoder:
97
+ proxy:
98
+ bind:
99
+ timeout:
100
+ open_timeout:
101
+ boundary:
102
+ oauth:
103
+ ssl: !ruby/struct:Faraday::SSLOptions
104
+ verify: true
105
+ ca_file:
106
+ ca_path:
107
+ verify_mode:
108
+ cert_store:
109
+ client_cert:
110
+ client_key:
111
+ certificate:
112
+ private_key:
113
+ verify_depth:
114
+ version:
115
+ symbolized_key_set: !ruby/object:Set
116
+ hash: {}
117
+ default_parallel_manager:
118
+ builder: !ruby/object:Faraday::RackBuilder
119
+ handlers:
120
+ - !ruby/object:Faraday::RackBuilder::Handler
121
+ name: Faraday::Request::UrlEncoded
122
+ args: []
123
+ block:
124
+ - !ruby/object:Faraday::RackBuilder::Handler
125
+ name: Faraday::Adapter::NetHttp
126
+ args: []
127
+ block:
128
+ app: !ruby/object:Faraday::Request::UrlEncoded
129
+ app: !ruby/object:Faraday::Adapter::NetHttp
130
+ app: !ruby/object:Proc {}
131
+ url_prefix: !ruby/object:URI::HTTPS
132
+ scheme: https
133
+ user:
134
+ password:
135
+ host: www.strava.com
136
+ port: 443
137
+ path: "/"
138
+ query:
139
+ opaque:
140
+ registry:
141
+ fragment:
142
+ parser:
143
+ proxy:
144
+ token: d6d3c5bab1694c4c8412294d529d523ab43a7059
145
+ refresh_token:
146
+ expires_in:
147
+ expires_at:
148
+ options:
149
+ :mode: :header
150
+ :header_format: Bearer %s
151
+ :param_name: access_token
152
+ params:
153
+ token_type: Bearer
154
+ athlete:
155
+ id: 558333
156
+ username: mathewxiang
157
+ resource_state: 3
158
+ firstname: matt
159
+ lastname: xiang
160
+ city: Tokyo, Japan
161
+ state: Tokyo
162
+ country: Japan
163
+ sex: M
164
+ premium: true
165
+ created_at: '2012-05-27T06:22:17Z'
166
+ updated_at: '2016-06-19T00:22:41Z'
167
+ badge_type_id: 1
168
+ profile_medium: https://dgalywyr863hv.cloudfront.net/pictures/athletes/558333/3176446/3/medium.jpg
169
+ profile: https://dgalywyr863hv.cloudfront.net/pictures/athletes/558333/3176446/3/large.jpg
170
+ friend:
171
+ follower:
172
+ follower_count: 11
173
+ friend_count: 55
174
+ mutual_friend_count: 0
175
+ athlete_type: 0
176
+ date_preference: "%m/%d/%Y"
177
+ measurement_preference: meters
178
+ email: xiangzhuyuan@gmail.com
179
+ ftp:
180
+ weight: 75.0
181
+ clubs:
182
+ - id: 134155
183
+ resource_state: 2
184
+ name: Paris-Brest-Paris Randonneur 2015
185
+ profile_medium: https://dgalywyr863hv.cloudfront.net/pictures/clubs/134155/2669527/2/medium.jpg
186
+ profile: https://dgalywyr863hv.cloudfront.net/pictures/clubs/134155/2669527/2/large.jpg
187
+ cover_photo:
188
+ cover_photo_small:
189
+ sport_type: cycling
190
+ member_count: 759
191
+ featured: false
192
+ url: parisbrest
193
+ bikes:
194
+ - id: b2338068
195
+ primary: true
196
+ name: giant 1
197
+ resource_state: 2
198
+ distance: 2231038.0
199
+ shoes:
200
+ - id: g1265409
201
+ primary: true
202
+ name: Nike Flyknit Max
203
+ resource_state: 2
204
+ distance: 211435.0
205
+
206
+ ```