Anyone here who can assist us with an issue parsin...
# general
r
Anyone here who can assist us with an issue parsing the state while signing in with Apple?
r
hey @rubenstolk can you share a stack trace as well as the state value? Are you doing anything to modify the default state we have?
r
Yes - probably by tomorrow
r
sounds good
r
Could you invite my colleage @masurceac here?
He just created this detailed description of the issue.
r
thanks. Will see that. Anyone can join this discord.
hmm
can you share the URL that is returned from when you call
getAuthorisationURLWithQueryParamsAndSetState
from the frontend?
also, which backend framework are you using along with our node sdk?
r
@masurceac
@rp_st can you grant access to @masurceac?
r
done
m
Hi @rp_st ! We are using React SPA + NestJS. Here's the URL returned from
getAuthorisationURLWithQueryParamsAndSetState
On backend we have this configuration for apple:
Copy code
authorizationEndpointQueryParams: {
                  scope: 'name email',
                  state: JSON.stringify({
                    frontendRedirectURI:
                      'https://smasurceac/ngrok.app' + '/auth/callback/apple',
                  }),
                  response_mode: 'form_post',
                  redirect_uri:
                    'https://smasurceac.ngrok.app' + '/auth/callback/apple',
                },
https://appleid.apple.com/auth/authorize?client_id=dev.teks.supertokens&redirect_uri=https%3A%2F%2Fsmasurceac.ngrok.app%2Fauth%2Fcallback%2Fapple&response_type=code&scope=name+email&response_mode=form_post&state=eyJzdGF0ZSI6IjYzODQ1MDJhZGIxMDI0NWRkYWNmOSJ9
r
right. So there is a state variable
hmm
m
I've added more
authorizationEndpointQueryParams
while trying to fix the issue, originally it was only
Copy code
authorizationEndpointQueryParams: {
                  scope: 'name email',
}
r
the value for redirectURIOnProviderDashboard should be your
<apiDomain>/<auth>/callback/apple
the issue is that you have used the localURL for that instead of the apiDomain
also, you don't need to define:
Copy code
state: JSON.stringify({
                    frontendRedirectURI:
                      'https://smasurceac/ngrok.app' + '/auth/callback/apple',
                  }),
in
authorizationEndpointQueryParams
on the backend
m
Copy code
const localURL = 'https://smasurceac.ngrok.app';

 const authUrl = await getAuthorisationURLWithQueryParamsAndSetState({
        thirdPartyId: provider,
        frontendRedirectURI: localURL + '/auth/callback/' + provider,
        ...(provider === 'apple'
          ? {
              redirectURIOnProviderDashboard: localURL + '/auth/callback/apple', // This URL goes on the Apple's dashboard
            }
          : {}),
      });
r
yea
so it should not be
redirectURIOnProviderDashboard: localURL + '/auth/callback/apple'
it should be
redirectURIOnProviderDashboard: apiDomain + '/auth/callback/apple'
m
Thanks @rp_st . I've set the localhost url for frontend and ngrok for backend and it worked. 👍
r
great