podio 0.4.0 → 0.4.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.
data/README.md CHANGED
@@ -29,9 +29,14 @@ After the configuration you need to authenticate against the API. The client sup
29
29
 
30
30
  ### Web Server Flow
31
31
 
32
- The default OAuth flow to be used when you authenticate Podio users from your web application.
32
+ The default OAuth flow to be used when you authenticate Podio users from your web application. See the `sinatra.rb` in the examples folder.
33
33
 
34
- Podio.client.authenticate_with_auth_code('AUTHORIZATION_CODE', redirect_uri)
34
+ # Redirect the user to the authorize url
35
+ Podio.client.authorize_url(:redirect_uri => redirect_uri)
36
+
37
+ # In the callback you get the authorization_code
38
+ # wich you use to get the access token
39
+ Podio.client.authenticate_with_auth_code(params[:code], redirect_uri)
35
40
 
36
41
  ### Username and Password Flow
37
42
 
@@ -0,0 +1,55 @@
1
+ #
2
+ # Basic OAuth web server flow example
3
+ #
4
+ # You need the sinatra and podio gems installed
5
+ # and provide your API key in the Podio.setup call
6
+ #
7
+ # Configure your API key on https://podio.com/settings/api
8
+ # so that the return URL is 'localhost'
9
+ #
10
+ # Start with
11
+ # ruby sinatra.rb
12
+ #
13
+ # And point your browser to http://localhost:4567
14
+ #
15
+
16
+ require 'rubygems'
17
+ require 'sinatra'
18
+ require 'podio'
19
+
20
+
21
+ # CHANGE this this to make this example work
22
+ Podio.setup(
23
+ :api_key => 'YOUR_API_KEY',
24
+ :api_secret => 'YOUR_API_SECRET'
25
+ )
26
+
27
+ get '/' do
28
+ %(<p>Update the <code>Podio.setup</code> call in the sinatra app and <a href="/auth/podio">try to authorize</a>.</p>)
29
+ end
30
+
31
+ # access this to request a token from Podio
32
+ get '/auth/podio' do
33
+ redirect Podio.client.authorize_url(:redirect_uri => redirect_uri)
34
+ end
35
+
36
+ # If the user authorizes it, this request gets your authorization code
37
+ # which is used to get an access token and make a successful api call
38
+ get '/auth/podio/callback' do
39
+ begin
40
+ # normally you store the token in the session to be able
41
+ # to make API calls with it in subsequent requests
42
+ token = Podio.client.authenticate_with_auth_code(params[:code], redirect_uri)
43
+ user = Podio::UserStatus.current
44
+
45
+ "<p><b>Your OAuth access token</b>: #{token.access_token}</p><p><b>Your user status info</b>:\n#{user.inspect}</p>"
46
+ rescue Podio::BadRequestError
47
+ %(<p>Outdated authorization code:</p><p>#{$!}</p><p><a href="/auth/podio">Start over</a></p>)
48
+ end
49
+ end
50
+
51
+ def redirect_uri(path='/auth/podio/callback')
52
+ uri = URI.parse(request.url)
53
+ uri.path = path
54
+ uri.to_s
55
+ end
data/lib/podio/client.rb CHANGED
@@ -30,6 +30,15 @@ module Podio
30
30
  setup_connections
31
31
  end
32
32
 
33
+ def authorize_url(params={})
34
+ uri = URI.parse(@api_url)
35
+ uri.host = uri.host.gsub('api.', '')
36
+ uri.path = '/oauth/authorize'
37
+ uri.query = Rack::Utils.build_query(params.merge(:client_id => api_key))
38
+
39
+ uri.to_s
40
+ end
41
+
33
42
  # sign in as a user using the server side flow
34
43
  def authenticate_with_auth_code(authorization_code, redirect_uri)
35
44
  response = @oauth_connection.post do |req|
data/lib/podio/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Podio
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: podio
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease:
4
+ prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 4
9
- - 0
10
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
11
10
  platform: ruby
12
11
  authors:
13
12
  - Florian Munz
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-05-14 00:00:00 +02:00
17
+ date: 2011-05-15 00:00:00 +02:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,7 +25,6 @@ dependencies:
26
25
  requirements:
27
26
  - - ~>
28
27
  - !ruby/object:Gem::Version
29
- hash: 3
30
28
  segments:
31
29
  - 0
32
30
  - 7
@@ -42,7 +40,6 @@ dependencies:
42
40
  requirements:
43
41
  - - ~>
44
42
  - !ruby/object:Gem::Version
45
- hash: 7
46
43
  segments:
47
44
  - 3
48
45
  - 0
@@ -57,7 +54,6 @@ dependencies:
57
54
  requirements:
58
55
  - - ">="
59
56
  - !ruby/object:Gem::Version
60
- hash: 11
61
57
  segments:
62
58
  - 0
63
59
  - 4
@@ -73,7 +69,6 @@ dependencies:
73
69
  requirements:
74
70
  - - ~>
75
71
  - !ruby/object:Gem::Version
76
- hash: 21
77
72
  segments:
78
73
  - 0
79
74
  - 0
@@ -97,6 +92,7 @@ files:
97
92
  - LICENSE
98
93
  - README.md
99
94
  - Rakefile
95
+ - examples/sinatra.rb
100
96
  - lib/podio.rb
101
97
  - lib/podio/areas/app_store.rb
102
98
  - lib/podio/areas/application.rb
@@ -155,7 +151,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
151
  requirements:
156
152
  - - ">="
157
153
  - !ruby/object:Gem::Version
158
- hash: 3
159
154
  segments:
160
155
  - 0
161
156
  version: "0"
@@ -164,14 +159,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
159
  requirements:
165
160
  - - ">="
166
161
  - !ruby/object:Gem::Version
167
- hash: 3
168
162
  segments:
169
163
  - 0
170
164
  version: "0"
171
165
  requirements: []
172
166
 
173
167
  rubyforge_project:
174
- rubygems_version: 1.4.2
168
+ rubygems_version: 1.3.7
175
169
  signing_key:
176
170
  specification_version: 3
177
171
  summary: Ruby wrapper for the Podio API