Module: Camper::Authorization
- Included in:
- Client
- Defined in:
- lib/camper/authorization.rb
Instance Method Summary collapse
- #authorization_uri ⇒ Object
- #authorize!(auth_code) ⇒ Object
- #authz_client ⇒ Object
- #update_access_token! ⇒ Object
Instance Method Details
#authorization_uri ⇒ Object
6 7 8 9 10 |
# File 'lib/camper/authorization.rb', line 6 def client = authz_client client. type: :web_server end |
#authorize!(auth_code) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/camper/authorization.rb', line 22 def (auth_code) client = authz_client client. = auth_code # Passing secrets as query string token = client.access_token!( client_auth_method: nil, client_id: @config.client_id, client_secret: @config.client_secret, type: :web_server ) store_tokens(token) token end |
#authz_client ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/camper/authorization.rb', line 12 def authz_client Rack::OAuth2::Client.new( identifier: @config.client_id, secret: @config.client_secret, redirect_uri: @config.redirect_uri, authorization_endpoint: @config.authz_endpoint, token_endpoint: @config.token_endpoint, ) end |
#update_access_token! ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/camper/authorization.rb', line 39 def update_access_token! logger.debug "Update access token using refresh token" client = authz_client client.refresh_token = @config.refresh_token token = client.access_token!( client_auth_method: nil, client_id: @config.client_id, client_secret: @config.client_secret, type: :refresh ) store_tokens(token) token end |