Class: GoogleApi::Auth
- Inherits:
-
Object
- Object
- GoogleApi::Auth
- Defined in:
- lib/google_api/auth.rb
Direct Known Subclasses
Constant Summary collapse
- ConfigMissingError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#redirect_uri ⇒ Object
readonly
Returns the value of attribute redirect_uri.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #authorize_url ⇒ Object
- #get_token(code) ⇒ Object
-
#initialize(access_token, redirect_uri, state: nil) ⇒ Auth
constructor
A new instance of Auth.
Constructor Details
#initialize(access_token, redirect_uri, state: nil) ⇒ Auth
Returns a new instance of Auth.
9 10 11 12 13 |
# File 'lib/google_api/auth.rb', line 9 def initialize(access_token, redirect_uri, state: nil) @access_token = access_token @redirect_uri = redirect_uri @state = state end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/google_api/auth.rb', line 5 def access_token @access_token end |
#redirect_uri ⇒ Object (readonly)
Returns the value of attribute redirect_uri.
5 6 7 |
# File 'lib/google_api/auth.rb', line 5 def redirect_uri @redirect_uri end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
5 6 7 |
# File 'lib/google_api/auth.rb', line 5 def state @state end |
Instance Method Details
#authorize_url ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/google_api/auth.rb', line 15 def client.auth_code.( redirect_uri: redirect_uri, scope: scope, state: state # This is used for arbitrary redirection ) end |
#get_token(code) ⇒ Object
23 24 25 26 |
# File 'lib/google_api/auth.rb', line 23 def get_token(code) ret = client.auth_code.get_token(code, redirect_uri: redirect_uri) [ret.token, ret.expires_at] end |