Skip to content

Commit 315b4ec

Browse files
committed
create sinatra example
1 parent ce4225a commit 315b4ec

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

exmaple/Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'sinatra'
4+
gem 'omniauth-fitbit-oauth2', :path => '../'

exmaple/config.ru

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require 'bundler/setup'
2+
require 'sinatra/base'
3+
require 'omniauth-fitbit-oauth2'
4+
5+
class App < Sinatra::Base
6+
get '/' do
7+
redirect '/auth/fitbit_oauth2'
8+
end
9+
10+
get '/auth/:provider/callback' do
11+
content_type 'application/json'
12+
MultiJson.encode(request.env)
13+
end
14+
15+
get '/auth/failure' do
16+
content_type 'application/json'
17+
MultiJson.encode(request.env)
18+
end
19+
end
20+
21+
use Rack::Session::Cookie
22+
23+
use OmniAuth::Builder do
24+
provider :fitbit_oauth2, ENV['FITBIT_CLIENT_ID'], ENV['FITBIT_CLIENT_SECRET'],
25+
:scope => 'activity sleep'
26+
end
27+
28+
run App.new

0 commit comments

Comments
 (0)