Class: SimpleGoogleAuth::OAuth
- Inherits:
-
Object
- Object
- SimpleGoogleAuth::OAuth
- Defined in:
- lib/simple_google_auth/oauth.rb
Instance Method Summary collapse
- #exchange_code_for_auth_token!(code) ⇒ Object
-
#initialize(config) ⇒ OAuth
constructor
A new instance of OAuth.
- #refresh_auth_token!(refresh_token) ⇒ Object
Constructor Details
#initialize(config) ⇒ OAuth
Returns a new instance of OAuth.
3 4 5 6 |
# File 'lib/simple_google_auth/oauth.rb', line 3 def initialize(config) @config = config @client = HttpClient.new(@config.google_token_url, @config.ca_path) end |
Instance Method Details
#exchange_code_for_auth_token!(code) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/simple_google_auth/oauth.rb', line 8 def exchange_code_for_auth_token!(code) response = @client.request( code: code, grant_type: "authorization_code", client_id: @config.client_id, client_secret: @config.client_secret, redirect_uri: @config.redirect_uri) parse_auth_response(response) end |
#refresh_auth_token!(refresh_token) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/simple_google_auth/oauth.rb', line 19 def refresh_auth_token!(refresh_token) return if refresh_token.blank? response = @client.request( refresh_token: refresh_token, client_id: @config.client_id, client_secret: @config.client_secret, grant_type: "refresh_token") parse_auth_response(response).merge("refresh_token" => refresh_token) end |