PasswordlessEmailRequest passes literal null when no ClientSecret provided for SPAs #797
Closed
5 tasks done
Labels
bug
This points to a verified bug in the code
Checklist
Description
I recently updated from 7.0.6 (I know, very old haha) to the most recent version. I noticed we were having errors with
PasswordlessEmailRequest
used inAuthenticationApiClient.StartPasswordlessEmailFlowAsync()
. In my case it was being used for a SPA so I only providedClientId
,Email
,Type
, andAuthenticationParameters
. This was working on 7.0.6 but after updating I started getting an error when using thiserror in client_secret - invalid type: null (expected string)
.The method was called like this
After some debugging I realized that when initializing a new
PasswordlessEmailRequest
theClientSecret
property has a default value ofnull
since it's astring
. But after looking at what actually happens in the methodauth0.net/src/Auth0.AuthenticationApi/AuthenticationApiClient.cs
Lines 409 to 412 in c654e7f
PasswordlessEmailRequest
it will pass the literal value ofnull
causing the error. Since this was being used for a SPA I don't need to provide aClientSecret
so this had me stumped for awhile. The fix ended up being initializing it to an empty stringThis seems like a confusing default behavior to have so it might be nice if that
else
statement was instead anelse if (!string.isNullOrEmpty(request.ClientSecret)
. I don't think there's any reason why someone would want to pass the literal valuenull
in any case. I assume this problem would also happen forStartPasswordlessSmsFlowAsync()
.Reproduction
StartPasswordlessEmailFlowAsync()
using aPasswordlessEmailRequest
for a SPA application with noClientSecret
value setclient_secret
is invalid typenull
Additional context
No response
auth0.net version
7.34
.NET version
.NET 9
The text was updated successfully, but these errors were encountered: