Class: Stytch::Impersonation
- Inherits:
-
Object
- Object
- Stytch::Impersonation
- Includes:
- RequestHelper
- Defined in:
- lib/stytch/impersonation.rb
Instance Method Summary collapse
-
#authenticate(impersonation_token:) ⇒ Object
Authenticate an impersonation token to impersonate a User.
-
#initialize(connection) ⇒ Impersonation
constructor
A new instance of Impersonation.
Methods included from RequestHelper
#delete_request, #get_request, #post_request, #put_request, #request_with_query_params
Constructor Details
#initialize(connection) ⇒ Impersonation
Returns a new instance of Impersonation.
15 16 17 |
# File 'lib/stytch/impersonation.rb', line 15 def initialize(connection) @connection = connection end |
Instance Method Details
#authenticate(impersonation_token:) ⇒ Object
Authenticate an impersonation token to impersonate a User. This endpoint requires an impersonation token that is not expired or previously used. A Stytch session will be created for the impersonated user with a 60 minute duration. Impersonated sessions cannot be extended.
Prior to this step, you can generate an impersonation token by visiting the Stytch Dashboard, viewing a user, and clicking the ‘Impersonate User` button.
Parameters:
- impersonation_token
-
The User Impersonation token to authenticate. Expires in 5 minutes by default. The type of this field is
String.
Returns:
An object with the following fields:
- request_id
-
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue. The type of this field is
String. - user_id
-
The unique ID of the affected User. The type of this field is
String. - user
-
The ‘user` object affected by this API call. See the [Get user endpoint](stytch.com/docs/api/get-user) for complete response field details. The type of this field is
User(object). - session_token
-
A secret token for a given Stytch Session. The type of this field is
String. - session_jwt
-
The JSON Web Token (JWT) for a given Stytch Session. The type of this field is
String. - status_code
-
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors. The type of this field is
Integer. - session
-
If you initiate a Session, by including ‘session_duration_minutes` in your authenticate call, you’ll receive a full Session object in the response.
See [Session object](stytch.com/docs/api/session-object) for complete response fields.
The type of this field is nilable
Session(object).
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/stytch/impersonation.rb', line 55 def authenticate( impersonation_token: ) headers = {} request = { impersonation_token: impersonation_token } post_request('/v1/impersonation/authenticate', request, headers) end |