blair6861
12/23/2022, 5:32 PMsupertokens-node
, is there a way to modify the config for a ThirdPartyEmailPassword
provider from within a recipe override?
More specifically, I am using a google as an identity provider and want to change the config params inside thirdPartySignInUpPOST
hook. I will have a login hint unique to users that I need to pass to google. Im passing the hint in the request body and need to set it in this hook.
I thought maybe I could modify the input
that is passed to the originalImplementation.thirdPartySignInUpPOST
call but it doesnt seem to contain the config data. I also made the config object passed to ThirdPartyEmailPassword.Google
global so that I could modify it, but it looks like the provider gets initialized before the point its modified.blair6861
12/23/2022, 8:34 PMTypeThirdPartyProviderGoogleConfig['authorisationRedirect']['params']
in the config could be a function that gets the request instead of a string, so I used that.
ts
ThirdPartyEmailPassword.Google({
clientId: config.clientId,
clientSecret: config.clientSecret,
scope: [ ... ],
authorisationRedirect: {
params: {
login_hint: (request: any) => {
const params = new URLSearchParams(request.url)
const someParam = params.get('someParam')
if(someParam){
return someParam
}
// dont want to return anything here
return ''
}
}
}
})
The problem is that I only want to set the login_hint
sometimes (when the parameter is added to the request). But currently I am forced to always set it or never set it. I see 2 ways this could be addressed:
1. The keys of TypeThirdPartyProviderGoogleConfig['authorisationRedirect']['params']
(and the other provider configs) could be changed to return a string or undefined, then the keys with undefined values could be filtered out. This was my first instinct.
2. TypeThirdPartyProviderGoogleConfig['authorisationRedirect']['params']
type could be expanded to also include a function with the request passed in which returns params
(similar to the keys on params which I utilized above).
Is there currently another workaround for this issue? Would you be open to a pull request implementing either of these?blair6861
12/23/2022, 8:37 PMthirdPartySignInUpPOST
hook? If so, that would be another way to solve this problem.porcellus
12/24/2022, 12:06 AMporcellus
12/24/2022, 12:08 AMrp_st
12/24/2022, 4:15 AMsattvikc
12/26/2022, 4:56 AMsattvikc
12/26/2022, 5:03 AMauthorisationUrlGET
, call the original implementation and then append login_hint
param to the url (whenever you need it) and return it.
2. In the method you are currently doing which forces you to send a value, you could return empty string instead of undefined in cases you don't need it. the google provider will ignore it.blair6861
01/12/2023, 6:38 PMSuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).
Powered by