Class: Vend::Oauth2::AuthCode
- Inherits:
-
Object
- Object
- Vend::Oauth2::AuthCode
- Defined in:
- lib/vend/oauth2/auth_code.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{}
- AUTHORIZE_URL =
'/connect'
- TOKEN_URL =
'/api/1.0/token'
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
-
#secret ⇒ Object
Returns the value of attribute secret.
-
#store ⇒ Object
Returns the value of attribute store.
Instance Method Summary collapse
- #authorize_url ⇒ Object
-
#initialize(store, client_id, secret, redirect_uri, options = {}) ⇒ AuthCode
constructor
A new instance of AuthCode.
- #refresh_token(auth_token, refresh_token) ⇒ Object
- #token_from_code(code) ⇒ Object
Constructor Details
#initialize(store, client_id, secret, redirect_uri, options = {}) ⇒ AuthCode
Returns a new instance of AuthCode.
12 13 14 15 16 17 18 |
# File 'lib/vend/oauth2/auth_code.rb', line 12 def initialize(store, client_id, secret, redirect_uri, = {}) @store = store @client_id = client_id @secret = secret @redirect_uri = redirect_uri @options = DEFAULT_OPTIONS.merge() end |
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
10 11 12 |
# File 'lib/vend/oauth2/auth_code.rb', line 10 def client_id @client_id end |
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
10 11 12 |
# File 'lib/vend/oauth2/auth_code.rb', line 10 def redirect_uri @redirect_uri end |
#secret ⇒ Object
Returns the value of attribute secret.
10 11 12 |
# File 'lib/vend/oauth2/auth_code.rb', line 10 def secret @secret end |
#store ⇒ Object
Returns the value of attribute store.
10 11 12 |
# File 'lib/vend/oauth2/auth_code.rb', line 10 def store @store end |
Instance Method Details
#authorize_url ⇒ Object
20 21 22 |
# File 'lib/vend/oauth2/auth_code.rb', line 20 def get_oauth2_client.auth_code.(redirect_uri: redirect_uri) end |
#refresh_token(auth_token, refresh_token) ⇒ Object
29 30 31 32 |
# File 'lib/vend/oauth2/auth_code.rb', line 29 def refresh_token(auth_token, refresh_token) access_token = OAuth2::AccessToken.new(get_oauth2_client(store), auth_token, {refresh_token: refresh_token}) access_token.refresh! end |
#token_from_code(code) ⇒ Object
24 25 26 27 |
# File 'lib/vend/oauth2/auth_code.rb', line 24 def token_from_code(code) client = get_oauth2_client(store) client.auth_code.get_token(code, redirect_uri: redirect_uri) end |