Class: Strava::OAuth::Client
- Inherits:
-
Web::Client
- Object
- Web::Client
- Strava::OAuth::Client
- Defined in:
- lib/strava/oauth/client.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#authorize_url(options = {}) ⇒ String
Obtain the request access URL.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#oauth_token(options = {}) ⇒ Hash
Complete the authentication process.
Methods inherited from Web::Client
Methods included from Web::Request
Constructor Details
Class Method Details
.config ⇒ Object
64 65 66 |
# File 'lib/strava/oauth/client.rb', line 64 def config Config end |
Instance Method Details
#authorize_url(options = {}) ⇒ String
Obtain the request access URL.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/strava/oauth/client.rb', line 28 def ( = {}) query = .merge( client_id: client_id || raise(ArgumentError, 'Missing Strava client id.'), response_type: [:response_type] || 'code', redirect_uri: [:redirect_uri] || 'http://localhost', approval_prompt: [:approval_prompt] || 'auto', scope: [:scope] || 'read' ) [endpoint, "authorize?#{query.to_query}"].join('/') end |
#oauth_token(options = {}) ⇒ Hash
Complete the authentication process.
49 50 51 52 53 54 55 56 57 |
# File 'lib/strava/oauth/client.rb', line 49 def oauth_token( = {}) query = .merge( client_id: client_id || raise(ArgumentError, 'Missing Strava client id.'), client_secret: client_secret || raise(ArgumentError, 'Missing Strava client secret.'), grant_type: [:grant_type] || 'authorization_code' ) Strava::Models::Token.new(post('token', query)) end |