Class: Gigya::OAuth
- Inherits:
-
Object
- Object
- Gigya::OAuth
- Defined in:
- lib/gigya/oauth.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
readonly
Returns the value of attribute client_secret.
-
#oauth_callback_url ⇒ Object
readonly
Returns the value of attribute oauth_callback_url.
Instance Method Summary collapse
- #get_token(code) ⇒ Object
-
#initialize(client_id, client_secret, oauth_callback_url = nil) ⇒ OAuth
constructor
A new instance of OAuth.
- #login(provider) ⇒ Object
Constructor Details
#initialize(client_id, client_secret, oauth_callback_url = nil) ⇒ OAuth
Returns a new instance of OAuth.
5 6 7 8 9 |
# File 'lib/gigya/oauth.rb', line 5 def initialize(client_id, client_secret, oauth_callback_url = nil) @client_id = client_id @client_secret = client_secret @oauth_callback_url = oauth_callback_url end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
3 4 5 |
# File 'lib/gigya/oauth.rb', line 3 def client_id @client_id end |
#client_secret ⇒ Object (readonly)
Returns the value of attribute client_secret.
3 4 5 |
# File 'lib/gigya/oauth.rb', line 3 def client_secret @client_secret end |
#oauth_callback_url ⇒ Object (readonly)
Returns the value of attribute oauth_callback_url.
3 4 5 |
# File 'lib/gigya/oauth.rb', line 3 def oauth_callback_url @oauth_callback_url end |
Instance Method Details
#get_token(code) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/gigya/oauth.rb', line 26 def get_token(code) params = { client_id: @client_id, client_secret: @client_secret, redirect_uri: @oauth_callback_url, grant_type: 'authorization_code', code: code } url = Gigya.build_url(Gigya::URLS[:socialize], Gigya::URIS[:get_token]) response = Gigya.connection.post(url, params) JSON.parse response.body end |
#login(provider) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gigya/oauth.rb', line 11 def login(provider) params = { client_id: @client_id, redirect_uri: @oauth_callback_url, response_type: 'code', x_provider: provider } url = Gigya.build_url(Gigya::URLS[:socialize], Gigya::URIS[:login]) response = Gigya.connection.get(url, params) response['location'] end |