Descope team, I’m trying to integrate Descope in m...
# ask-a-descoper
b
Descope team, I’m trying to integrate Descope in my Sveltekit app with AuthJS. But the Descope redirect keeps saying that ‘state’ Is required. Auth0, Google and every other provider works seamlessly over there. Can the team please help with creation of a Descope and AuthJS project? Any framework example would be sufficient. I’m not sure what I’m missing.
s
@brash-pencil-33614 would a nextjs/nextAuth sample app help you for this? We have one we can make public and share the github.
a
Hi, this is an example with Nextjs https://github.com/descope/nextjs-hackathon-template Can you please share a screenshot of your SSO > Identity Provider page?
And also a snippet of the Descope provider settings in Svelte.
Also, in case you have a value in approved domains settings, make sure to add
<http://auth.descope.io|auth.descope.io>
as well.
b
@ancient-motorcycle-2291 here you go
I have not added any domains in the approved domains list right now
a
Ok good. Can you just share the auth provider code in your svelte app?
b
sure
@ancient-motorcycle-2291 here it is
where clientID and secret has been generated from this page. I hope this is correct
a
Client id should be the project id. Client secret is indeed the access key.
b
ohh.. ok. so in both issuer and client ID, project ID has to be passed
and access key ID is of no use? only secret is used?
a
Right. Actually if you are using the last descope provider only the client id should pass.
You can also use it like the following with our wrapper
Check the snippet here
b
Copy code
{
  "errorCode": "E011003",
  "errorDescription": "Request is invalid",
  "errorMessage": "The state field is required",
  "message": "The state field is required"
}
I keep getting this error
a
b
let me try to fork the above project and then try on it. Configurations are same, as directed in video
apart from custom domain name
since
state
field is automatically added by library, I am thinking if this could be a library version issue from AuthJS
let me try the example first though
a
ok
sure
b
@ancient-motorcycle-2291 though the above example also break, unless the line
checks: ['pkce', 'state'],
is added
that is the magic line that makes it work
thank you for the quick help!
a
Yes, they require it to send the state. Great
So you managed to login with it?
b
yeah
now everything is working @ancient-motorcycle-2291
one last question, every time I sign out, I have to login at Descope again. Is there any way that Descope maintains the session from quick SSO perspective?
a
Can you check your cookie settings in the project page? What is the cookie domain you have there?
The main problem is because you have custom domain and the cookie domain is set to your custom domain. The OIDC page domain is
<http://auth.descope.io|auth.descope.io>
, and the cookie does not apply by the browser. For now, what you can do is: Deploy that page by yourself in vercel (or other service), so you can control the domain (and also styles): https://github.com/descope/auth-hosting#descope-authentication-hosting-app, check the deploy to vercel button. We are working on an OOTB solution that will work for
<http://auth.descope.io|auth.descope.io>
b
Hmm. 👍🏼
Got it
@ancient-motorcycle-2291 while the implementation was working fine, I have started receiving this error now whenever the flow is initialised. I notice the extra
/login
being asked on the below page as opposed to to
<https://auth.descope.io/PROJECT_ID>
that used to work previously. What has changed and what changes we need to do in project to make this work?
@ancient-motorcycle-2291 got it working. But had to clear the cookies. How can we handle use cases like this?
a
@orange-belgium-27264 @rapid-doctor-25622 please check this out