Class: ScreenshotFreeAPI::Resources::Auth
- Inherits:
-
Object
- Object
- ScreenshotFreeAPI::Resources::Auth
- Defined in:
- lib/screenshotfreeapi/resources/auth.rb
Overview
Authentication endpoints — registration, API key management, and JWT tokens.
Note: ‘token` and `refresh` return JWTs that should be passed as the `jwt:` parameter to billing, workspace, and monitor resource methods.
Instance Method Summary collapse
-
#initialize(http) ⇒ Auth
constructor
A new instance of Auth.
-
#refresh(refresh_token:) ⇒ Hash
Refresh an expired JWT using a refresh token.
-
#register(email:, password:, name:) ⇒ Hash
Register a new account.
-
#token(email:, password:) ⇒ Hash
Obtain a management JWT by providing account credentials.
Constructor Details
#initialize(http) ⇒ Auth
Returns a new instance of Auth.
10 11 12 |
# File 'lib/screenshotfreeapi/resources/auth.rb', line 10 def initialize(http) @http = http end |
Instance Method Details
#refresh(refresh_token:) ⇒ Hash
Refresh an expired JWT using a refresh token.
51 52 53 54 55 |
# File 'lib/screenshotfreeapi/resources/auth.rb', line 51 def refresh(refresh_token:) @http.request(:post, "/auth/refresh", body: { refreshToken: refresh_token }) end |
#register(email:, password:, name:) ⇒ Hash
Register a new account.
22 23 24 25 26 27 28 |
# File 'lib/screenshotfreeapi/resources/auth.rb', line 22 def register(email:, password:, name:) @http.request(:post, "/auth/register", body: { email: email, password: password, name: name }) end |
#token(email:, password:) ⇒ Hash
Obtain a management JWT by providing account credentials.
The returned token is required for billing, workspace, and monitor endpoints. Pass it as ‘jwt:` to those resource methods.
39 40 41 42 43 44 |
# File 'lib/screenshotfreeapi/resources/auth.rb', line 39 def token(email:, password:) @http.request(:post, "/auth/token", body: { email: email, password: password }) end |