Class: ShakeTheCounter::Authentication
- Inherits:
-
Object
- Object
- ShakeTheCounter::Authentication
- Defined in:
- lib/shake_the_counter/authentication.rb
Overview
This class handles the login logic. Shake The Counter uses OAuth
A HTTP POST request must be done to apitest.shakethecounter.com/token (the authorization server) with the following information: Header Content-Type must be set to application/form-url-encoded
Class Method Summary collapse
-
.get_access_token(client_id: '', client_secret: '', username: '', password: '') ⇒ Object
Gets the authentication_token and refresh_token from a username and password.
-
.renew_access_token(client_id: '', client_secret: '', refresh_token: '') ⇒ Object
Renews the access token from the refresh token.
Class Method Details
.get_access_token(client_id: '', client_secret: '', username: '', password: '') ⇒ Object
Gets the authentication_token and refresh_token from a username and password.
body: grant_type=password&client_id=clientid&client_secret=clientsecret&username=username&password=password
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/shake_the_counter/authentication.rb', line 44 def self.get_access_token(client_id: '', client_secret: '', username: '', password: '') body = { grant_type: "password", client_id: client_id, client_secret: client_secret, username: username, password: password } header = { content_type: "application/x-www-form-urlencoded" } result = ShakeTheCounter::API.call( "#{ShakeTheCounter::API.endpoint}/token", http_method: :post, header: header, body: body ) end |
.renew_access_token(client_id: '', client_secret: '', refresh_token: '') ⇒ Object
Renews the access token from the refresh token. auth0.com/learn/refresh-tokens/
body: grant_type=refresh_token&client_id=clientid&client_secret=clientsecret&refresh_token=refreshToken
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/shake_the_counter/authentication.rb', line 19 def self.renew_access_token(client_id: '', client_secret: '', refresh_token: '') body = { grant_type: "refresh_token", client_id: client_id, client_secret: client_secret, refresh_token: refresh_token } result = ShakeTheCounter::API.call( "#{ShakeTheCounter::API.endpoint}/token", http_method: :post, body: body, header: {content_type: "application/x-www-form-urlencoded"} ) end |