stytch 5.0.2 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # !!!
4
+ # WARNING: This file is autogenerated
5
+ # Only modify code within MANUAL() sections
6
+ # or your changes may be overwritten later!
7
+ # !!!
8
+
3
9
  require_relative 'request_helper'
4
10
 
5
11
  module StytchB2B
@@ -14,13 +20,91 @@ module StytchB2B
14
20
  @discovery = StytchB2B::MagicLinks::Discovery.new(@connection)
15
21
  end
16
22
 
23
+ # Authenticate a Member with a Magic Link. This endpoint requires a Magic Link token that is not expired or previously used. If the Member’s status is `pending` or `invited`, they will be updated to `active`. Provide the `session_duration_minutes` parameter to set the lifetime of the session. If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration.
24
+ #
25
+ # == Parameters:
26
+ # magic_links_token::
27
+ # The Email Magic Link token to authenticate.
28
+ # The type of this field is +String+.
29
+ # pkce_code_verifier::
30
+ # A base64url encoded one time secret used to validate that the request starts and ends on the same device.
31
+ # The type of this field is nilable +String+.
32
+ # session_token::
33
+ # Reuse an existing session instead of creating a new one. If you provide a `session_token`, Stytch will update the session.
34
+ # If the `session_token` and `magic_links_token` belong to different Members, the `session_token` will be ignored. This endpoint will error if
35
+ # both `session_token` and `session_jwt` are provided.
36
+ # The type of this field is nilable +String+.
37
+ # session_jwt::
38
+ # Reuse an existing session instead of creating a new one. If you provide a `session_jwt`, Stytch will update the session. If the `session_jwt`
39
+ # and `magic_links_token` belong to different Members, the `session_jwt` will be ignored. This endpoint will error if both `session_token` and `session_jwt`
40
+ # are provided.
41
+ # The type of this field is nilable +String+.
42
+ # session_duration_minutes::
43
+ # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
44
+ # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
45
+ # five minutes regardless of the underlying session duration, and will need to be refreshed over time.
46
+ #
47
+ # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
48
+ #
49
+ # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
50
+ #
51
+ # If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration. If you don't want
52
+ # to use the Stytch session product, you can ignore the session fields in the response.
53
+ # The type of this field is nilable +Integer+.
54
+ # session_custom_claims::
55
+ # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in
56
+ # `session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To
57
+ # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
58
+ # Total custom claims size cannot exceed four kilobytes.
59
+ # The type of this field is nilable +object+.
60
+ # locale::
61
+ # (no documentation yet)
62
+ # The type of this field is nilable +AuthenticateRequestLocale+ (string enum).
63
+ #
64
+ # == Returns:
65
+ # An object with the following fields:
66
+ # request_id::
67
+ # 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.
68
+ # The type of this field is +String+.
69
+ # member_id::
70
+ # Globally unique UUID that identifies a specific Member.
71
+ # The type of this field is +String+.
72
+ # method_id::
73
+ # The email or device involved in the authentication.
74
+ # The type of this field is +String+.
75
+ # reset_sessions::
76
+ # Indicates if all Sessions linked to the Member need to be reset. You should check this field if you aren't using
77
+ # Stytch's Session product. If you are using Stytch's Session product, we revoke the Member’s other Sessions for you.
78
+ # The type of this field is +Boolean+.
79
+ # organization_id::
80
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
81
+ # The type of this field is +String+.
82
+ # member::
83
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object).
84
+ # The type of this field is +Member+ (+object+).
85
+ # session_token::
86
+ # A secret token for a given Stytch Session.
87
+ # The type of this field is +String+.
88
+ # session_jwt::
89
+ # The JSON Web Token (JWT) for a given Stytch Session.
90
+ # The type of this field is +String+.
91
+ # member_session::
92
+ # The [Session object](https://stytch.com/docs/b2b/api/session-object).
93
+ # The type of this field is +MemberSession+ (+object+).
94
+ # organization::
95
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
96
+ # The type of this field is +Organization+ (+object+).
97
+ # status_code::
98
+ # 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.
99
+ # The type of this field is +Integer+.
17
100
  def authenticate(
18
101
  magic_links_token:,
19
102
  pkce_code_verifier: nil,
20
103
  session_token: nil,
21
104
  session_jwt: nil,
22
105
  session_duration_minutes: nil,
23
- session_custom_claims: nil
106
+ session_custom_claims: nil,
107
+ locale: nil
24
108
  )
25
109
  request = {
26
110
  magic_links_token: magic_links_token
@@ -30,6 +114,7 @@ module StytchB2B
30
114
  request[:session_jwt] = session_jwt unless session_jwt.nil?
31
115
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
32
116
  request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
117
+ request[:locale] = locale unless locale.nil?
33
118
 
34
119
  post_request('/v1/b2b/magic_links/authenticate', request)
35
120
  end
@@ -44,6 +129,65 @@ module StytchB2B
44
129
  @discovery = StytchB2B::MagicLinks::Email::Discovery.new(@connection)
45
130
  end
46
131
 
132
+ # Send either a login or signup magic link to a Member. A new, pending, or invited Member will receive a signup Email Magic Link. Members will have a `pending` status until they successfully authenticate. An active Member will receive a login Email Magic Link.
133
+ #
134
+ # == Parameters:
135
+ # organization_id::
136
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
137
+ # The type of this field is +String+.
138
+ # email_address::
139
+ # The email address of the Member.
140
+ # The type of this field is +String+.
141
+ # login_redirect_url::
142
+ # The URL that the Member clicks from the login Email Magic Link. This URL should be an endpoint in the backend server that
143
+ # verifies the request by querying Stytch's authenticate endpoint and finishes the login. If this value is not passed, the default login
144
+ # redirect URL that you set in your Dashboard is used. If you have not set a default login redirect URL, an error is returned.
145
+ # The type of this field is nilable +String+.
146
+ # signup_redirect_url::
147
+ # The URL the Member clicks from the signup Email Magic Link. This URL should be an endpoint in the backend server that verifies
148
+ # the request by querying Stytch's authenticate endpoint and finishes the login. If this value is not passed, the default sign-up redirect URL
149
+ # that you set in your Dashboard is used. If you have not set a default sign-up redirect URL, an error is returned.
150
+ # The type of this field is nilable +String+.
151
+ # pkce_code_challenge::
152
+ # A base64url encoded SHA256 hash of a one time secret used to validate that the request starts and ends on the same device.
153
+ # The type of this field is nilable +String+.
154
+ # login_template_id::
155
+ # Use a custom template for login emails. By default, it will use your default email template. The template must be from Stytch's
156
+ # built-in customizations or a custom HTML email for Magic Links - Login.
157
+ # The type of this field is nilable +String+.
158
+ # signup_template_id::
159
+ # Use a custom template for signup emails. By default, it will use your default email template. The template must be from Stytch's
160
+ # built-in customizations or a custom HTML email for Magic Links - Signup.
161
+ # The type of this field is nilable +String+.
162
+ # locale::
163
+ # Used to determine which language to use when sending the user this delivery method. Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
164
+ #
165
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
166
+ #
167
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
168
+ #
169
+ # The type of this field is nilable +LoginOrSignupRequestLocale+ (string enum).
170
+ #
171
+ # == Returns:
172
+ # An object with the following fields:
173
+ # request_id::
174
+ # 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.
175
+ # The type of this field is +String+.
176
+ # member_id::
177
+ # Globally unique UUID that identifies a specific Member.
178
+ # The type of this field is +String+.
179
+ # member_created::
180
+ # A flag indicating `true` if a new Member object was created and `false` if the Member object already existed.
181
+ # The type of this field is +Boolean+.
182
+ # member::
183
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object).
184
+ # The type of this field is +Member+ (+object+).
185
+ # organization::
186
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
187
+ # The type of this field is +Organization+ (+object+).
188
+ # status_code::
189
+ # 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.
190
+ # The type of this field is +Integer+.
47
191
  def login_or_signup(
48
192
  organization_id:,
49
193
  email_address:,
@@ -68,6 +212,64 @@ module StytchB2B
68
212
  post_request('/v1/b2b/magic_links/email/login_or_signup', request)
69
213
  end
70
214
 
215
+ # Send an invite email to a new Member to join an Organization. The Member will be created with an `invited` status until they successfully authenticate. Sending invites to `pending` Members will update their status to `invited`. Sending invites to already `active` Members will return an error.
216
+ #
217
+ # == Parameters:
218
+ # organization_id::
219
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
220
+ # The type of this field is +String+.
221
+ # email_address::
222
+ # The email address of the Member.
223
+ # The type of this field is +String+.
224
+ # invite_redirect_url::
225
+ # The URL that the Member clicks from the invite Email Magic Link. This URL should be an endpoint in the backend server that verifies
226
+ # the request by querying Stytch's authenticate endpoint and finishes the invite flow. If this value is not passed, the default `invite_redirect_url`
227
+ # that you set in your Dashboard is used. If you have not set a default `invite_redirect_url`, an error is returned.
228
+ # The type of this field is nilable +String+.
229
+ # invited_by_member_id::
230
+ # The `member_id` of the Member who sends the invite.
231
+ # The type of this field is nilable +String+.
232
+ # name::
233
+ # The name of the Member.
234
+ # The type of this field is nilable +String+.
235
+ # trusted_metadata::
236
+ # An arbitrary JSON object for storing application-specific data or identity-provider-specific data.
237
+ # The type of this field is nilable +object+.
238
+ # untrusted_metadata::
239
+ # An arbitrary JSON object of application-specific data. These fields can be edited directly by the
240
+ # frontend SDK, and should not be used to store critical information. See the [Metadata resource](https://stytch.com/docs/b2b/api/metadata)
241
+ # for complete field behavior details.
242
+ # The type of this field is nilable +object+.
243
+ # invite_template_id::
244
+ # Use a custom template for invite emails. By default, it will use your default email template. The template must be a template
245
+ # using our built-in customizations or a custom HTML email for Magic Links - Invite.
246
+ # The type of this field is nilable +String+.
247
+ # locale::
248
+ # Used to determine which language to use when sending the user this delivery method. Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
249
+ #
250
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
251
+ #
252
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
253
+ #
254
+ # The type of this field is nilable +InviteRequestLocale+ (string enum).
255
+ #
256
+ # == Returns:
257
+ # An object with the following fields:
258
+ # request_id::
259
+ # 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.
260
+ # The type of this field is +String+.
261
+ # member_id::
262
+ # Globally unique UUID that identifies a specific Member.
263
+ # The type of this field is +String+.
264
+ # member::
265
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object).
266
+ # The type of this field is +Member+ (+object+).
267
+ # organization::
268
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
269
+ # The type of this field is +Organization+ (+object+).
270
+ # status_code::
271
+ # 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.
272
+ # The type of this field is +Integer+.
71
273
  def invite(
72
274
  organization_id:,
73
275
  email_address:,
@@ -101,6 +303,41 @@ module StytchB2B
101
303
  @connection = connection
102
304
  end
103
305
 
306
+ # Send a discovery magic link to an email address.
307
+ #
308
+ # == Parameters:
309
+ # email_address::
310
+ # The email address of the Member.
311
+ # The type of this field is +String+.
312
+ # discovery_redirect_url::
313
+ # The URL that the end user clicks from the discovery Magic Link. This URL should be an endpoint in the backend server that
314
+ # verifies the request by querying Stytch's discovery authenticate endpoint and continues the flow. If this value is not passed, the default
315
+ # discovery redirect URL that you set in your Dashboard is used. If you have not set a default discovery redirect URL, an error is returned.
316
+ # The type of this field is nilable +String+.
317
+ # pkce_code_challenge::
318
+ # A base64url encoded SHA256 hash of a one time secret used to validate that the request starts and ends on the same device.
319
+ # The type of this field is nilable +String+.
320
+ # login_template_id::
321
+ # Use a custom template for discovery emails. By default, it will use your default email template. The template must be from Stytch's
322
+ # built-in customizations or a custom HTML email for Magic Links - Login.
323
+ # The type of this field is nilable +String+.
324
+ # locale::
325
+ # Used to determine which language to use when sending the user this delivery method. Parameter is a [IETF BCP 47 language tag](https://www.w3.org/International/articles/language-tags/), e.g. `"en"`.
326
+ #
327
+ # Currently supported languages are English (`"en"`), Spanish (`"es"`), and Brazilian Portuguese (`"pt-br"`); if no value is provided, the copy defaults to English.
328
+ #
329
+ # Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
330
+ #
331
+ # The type of this field is nilable +SendRequestLocale+ (string enum).
332
+ #
333
+ # == Returns:
334
+ # An object with the following fields:
335
+ # request_id::
336
+ # 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.
337
+ # The type of this field is +String+.
338
+ # status_code::
339
+ # 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.
340
+ # The type of this field is +Integer+.
104
341
  def send(
105
342
  email_address:,
106
343
  discovery_redirect_url: nil,
@@ -128,6 +365,44 @@ module StytchB2B
128
365
  @connection = connection
129
366
  end
130
367
 
368
+ # Authenticates the Discovery Magic Link token and exchanges it for an Intermediate Session Token. Intermediate Session Tokens can be used for various Discovery login flows and are valid for 10 minutes.
369
+ #
370
+ # == Parameters:
371
+ # discovery_magic_links_token::
372
+ # The Discovery Email Magic Link token to authenticate.
373
+ # The type of this field is +String+.
374
+ # pkce_code_verifier::
375
+ # A base64url encoded one time secret used to validate that the request starts and ends on the same device.
376
+ # The type of this field is nilable +String+.
377
+ #
378
+ # == Returns:
379
+ # An object with the following fields:
380
+ # request_id::
381
+ # 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.
382
+ # The type of this field is +String+.
383
+ # intermediate_session_token::
384
+ # The Intermediate Session Token. This token does not belong to a specific instance of a member, but may be exchanged for an existing Member Session or used to create a new organization.
385
+ # The type of this field is +String+.
386
+ # email_address::
387
+ # The email address.
388
+ # The type of this field is +String+.
389
+ # discovered_organizations::
390
+ # An array of `discovered_organization` objects tied to the `intermediate_session_token`, `session_token`, or `session_jwt`. See the [Discovered Organization Object](https://stytch.com/docs/b2b/api/discovered-organization-object) for complete details.
391
+ #
392
+ # Note that Organizations will only appear here under any of the following conditions:
393
+ # 1. The end user is already a Member of the Organization.
394
+ # 2. The end user is invited to the Organization.
395
+ # 3. The end user can join the Organization because:
396
+ #
397
+ # a) The Organization allows JIT provisioning.
398
+ #
399
+ # b) The Organizations' allowed domains list contains the Member's email domain.
400
+ #
401
+ # c) The Organization has at least one other Member with a verified email address with the same domain as the end user (to prevent phishing attacks).
402
+ # The type of this field is list of +DiscoveredOrganization+ (+object+).
403
+ # status_code::
404
+ # 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.
405
+ # The type of this field is +Integer+.
131
406
  def authenticate(
132
407
  discovery_magic_links_token:,
133
408
  pkce_code_verifier: nil
@@ -0,0 +1,202 @@
1
+ # frozen_string_literal: true
2
+
3
+ # !!!
4
+ # WARNING: This file is autogenerated
5
+ # Only modify code within MANUAL() sections
6
+ # or your changes may be overwritten later!
7
+ # !!!
8
+
9
+ require_relative 'request_helper'
10
+
11
+ module StytchB2B
12
+ class OAuth
13
+ include Stytch::RequestHelper
14
+ attr_reader :discovery
15
+
16
+ def initialize(connection)
17
+ @connection = connection
18
+
19
+ @discovery = StytchB2B::OAuth::Discovery.new(@connection)
20
+ end
21
+
22
+ # Authenticate a Member given a `token`. This endpoint verifies that the member completed the OAuth flow by verifying that the token is valid and hasn't expired. Provide the `session_duration_minutes` parameter to set the lifetime of the session. If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration.
23
+ #
24
+ # == Parameters:
25
+ # oauth_token::
26
+ # The token to authenticate.
27
+ # The type of this field is +String+.
28
+ # session_token::
29
+ # A secret token for a given Stytch Session.
30
+ # The type of this field is nilable +String+.
31
+ # session_duration_minutes::
32
+ # Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
33
+ # returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
34
+ # five minutes regardless of the underlying session duration, and will need to be refreshed over time.
35
+ #
36
+ # This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
37
+ #
38
+ # If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
39
+ #
40
+ # If the `session_duration_minutes` parameter is not specified, a Stytch session will be created with a 60 minute duration. If you don't want
41
+ # to use the Stytch session product, you can ignore the session fields in the response.
42
+ # The type of this field is nilable +Integer+.
43
+ # session_jwt::
44
+ # The JSON Web Token (JWT) for a given Stytch Session.
45
+ # The type of this field is nilable +String+.
46
+ # session_custom_claims::
47
+ # Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in
48
+ # `session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To
49
+ # delete a key, supply a null value. Custom claims made with reserved claims (`iss`, `sub`, `aud`, `exp`, `nbf`, `iat`, `jti`) will be ignored.
50
+ # Total custom claims size cannot exceed four kilobytes.
51
+ # The type of this field is nilable +object+.
52
+ # pkce_code_verifier::
53
+ # A base64url encoded one time secret used to validate that the request starts and ends on the same device.
54
+ # The type of this field is nilable +String+.
55
+ # locale::
56
+ # (no documentation yet)
57
+ # The type of this field is nilable +AuthenticateRequestLocale+ (string enum).
58
+ #
59
+ # == Returns:
60
+ # An object with the following fields:
61
+ # request_id::
62
+ # 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.
63
+ # The type of this field is +String+.
64
+ # member_id::
65
+ # Globally unique UUID that identifies a specific Member.
66
+ # The type of this field is +String+.
67
+ # provider_subject::
68
+ # (no documentation yet)
69
+ # The type of this field is +String+.
70
+ # provider_type::
71
+ # (no documentation yet)
72
+ # The type of this field is +String+.
73
+ # session_token::
74
+ # A secret token for a given Stytch Session.
75
+ # The type of this field is +String+.
76
+ # session_jwt::
77
+ # The JSON Web Token (JWT) for a given Stytch Session.
78
+ # The type of this field is +String+.
79
+ # member::
80
+ # The [Member object](https://stytch.com/docs/b2b/api/member-object).
81
+ # The type of this field is +Member+ (+object+).
82
+ # organization_id::
83
+ # Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
84
+ # The type of this field is +String+.
85
+ # organization::
86
+ # The [Organization object](https://stytch.com/docs/b2b/api/organization-object).
87
+ # The type of this field is +Organization+ (+object+).
88
+ # reset_sessions::
89
+ # (no documentation yet)
90
+ # The type of this field is +Boolean+.
91
+ # status_code::
92
+ # 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.
93
+ # The type of this field is +Integer+.
94
+ # member_session::
95
+ # The [Session object](https://stytch.com/docs/b2b/api/session-object).
96
+ # The type of this field is nilable +MemberSession+ (+object+).
97
+ # provider_values::
98
+ # The `provider_values` object lists relevant identifiers, values, and scopes for a given OAuth provider. For example this object will include a provider's `access_token` that you can use to access the provider's API for a given user.
99
+ #
100
+ # Note that these values will vary based on the OAuth provider in question, e.g. `id_token` is only returned by Microsoft.
101
+ # The type of this field is nilable +ProviderValues+ (+object+).
102
+ def authenticate(
103
+ oauth_token:,
104
+ session_token: nil,
105
+ session_duration_minutes: nil,
106
+ session_jwt: nil,
107
+ session_custom_claims: nil,
108
+ pkce_code_verifier: nil,
109
+ locale: nil
110
+ )
111
+ request = {
112
+ oauth_token: oauth_token
113
+ }
114
+ request[:session_token] = session_token unless session_token.nil?
115
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
116
+ request[:session_jwt] = session_jwt unless session_jwt.nil?
117
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
118
+ request[:pkce_code_verifier] = pkce_code_verifier unless pkce_code_verifier.nil?
119
+ request[:locale] = locale unless locale.nil?
120
+
121
+ post_request('/v1/b2b/oauth/authenticate', request)
122
+ end
123
+
124
+ class Discovery
125
+ include Stytch::RequestHelper
126
+
127
+ def initialize(connection)
128
+ @connection = connection
129
+ end
130
+
131
+ # Authenticates the Discovery OAuth token and exchanges it for an Intermediate Session Token. Intermediate Session Tokens can be used for various Discovery login flows and are valid for 10 minutes.
132
+ #
133
+ # == Parameters:
134
+ # discovery_oauth_token::
135
+ # The Discovery OAuth token to authenticate.
136
+ # The type of this field is +String+.
137
+ # session_token::
138
+ # (no documentation yet)
139
+ # The type of this field is nilable +String+.
140
+ # session_duration_minutes::
141
+ # (no documentation yet)
142
+ # The type of this field is nilable +Integer+.
143
+ # session_jwt::
144
+ # (no documentation yet)
145
+ # The type of this field is nilable +String+.
146
+ # session_custom_claims::
147
+ # (no documentation yet)
148
+ # The type of this field is nilable +object+.
149
+ # pkce_code_verifier::
150
+ # A base64url encoded one time secret used to validate that the request starts and ends on the same device.
151
+ # The type of this field is nilable +String+.
152
+ #
153
+ # == Returns:
154
+ # An object with the following fields:
155
+ # request_id::
156
+ # 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.
157
+ # The type of this field is +String+.
158
+ # intermediate_session_token::
159
+ # The Intermediate Session Token. This token does not belong to a specific instance of a member, but may be exchanged for an existing Member Session or used to create a new organization.
160
+ # The type of this field is +String+.
161
+ # email_address::
162
+ # The email address.
163
+ # The type of this field is +String+.
164
+ # discovered_organizations::
165
+ # An array of `discovered_organization` objects tied to the `intermediate_session_token`, `session_token`, or `session_jwt`. See the [Discovered Organization Object](https://stytch.com/docs/b2b/api/discovered-organization-object) for complete details.
166
+ #
167
+ # Note that Organizations will only appear here under any of the following conditions:
168
+ # 1. The end user is already a Member of the Organization.
169
+ # 2. The end user is invited to the Organization.
170
+ # 3. The end user can join the Organization because:
171
+ #
172
+ # a) The Organization allows JIT provisioning.
173
+ #
174
+ # b) The Organizations' allowed domains list contains the Member's email domain.
175
+ #
176
+ # c) The Organization has at least one other Member with a verified email address with the same domain as the end user (to prevent phishing attacks).
177
+ # The type of this field is list of +DiscoveredOrganization+ (+object+).
178
+ # status_code::
179
+ # 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.
180
+ # The type of this field is +Integer+.
181
+ def authenticate(
182
+ discovery_oauth_token:,
183
+ session_token: nil,
184
+ session_duration_minutes: nil,
185
+ session_jwt: nil,
186
+ session_custom_claims: nil,
187
+ pkce_code_verifier: nil
188
+ )
189
+ request = {
190
+ discovery_oauth_token: discovery_oauth_token
191
+ }
192
+ request[:session_token] = session_token unless session_token.nil?
193
+ request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
194
+ request[:session_jwt] = session_jwt unless session_jwt.nil?
195
+ request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
196
+ request[:pkce_code_verifier] = pkce_code_verifier unless pkce_code_verifier.nil?
197
+
198
+ post_request('/v1/b2b/oauth/discovery/authenticate', request)
199
+ end
200
+ end
201
+ end
202
+ end