I noticed Auth.js has a change to support Descope ...
# ask-a-descoper
c
I noticed Auth.js has a change to support Descope so im trying to use Auth.js with Sveltekit. I have the following
Copy code
export const handle = SvelteKitAuth({
    providers: [
        {
          id: "descope",
          name: "Descope",
          type: "oidc",
          issuer: "<https://api.descope.com/ISSUER>",
          clientId: "ISSUER"",
          wellKnown: "<https://api.descope.com/ISSUER>"/.well-known/openid-configuration",
          clientSecret: 'CLIENT_SECRET',
        } satisfies OIDCConfig
      ]
});
im getting the following error
Copy code
{
  "errorCode": "E011003",
  "errorDescription": "Request is invalid",
  "errorMessage": "The state field is required",
  "message": "The state field is required"
}
any ideas? or if anyone has an example of using Descope flows with Sveltekit i would love to see it.
a
Hi @clever-laptop-72507 That’s correct. If you go to Authentication Methods > SSO > Identify Provider What do you have in the redirect url?
Adding @important-microphone-85224 to the thread
c
and i have localhost in the approved domains section as well
a
I see. The redirect url should point to a page which hosts the login flow. At the moment Descope doesn’t host the login flow but, it will be added very soon. @rapid-doctor-25622 Until then you can just have a page in your app the have the login flow and change the redirect url to that page. Once done everything should happen automatically.
c
thanks ill try that now
a
In this article you should have explanation about the redirect url and other things that might be helpful: https://docs.descope.com/customize/auth/oidc/
Let me know how it goes
r
HI @clever-laptop-72507 👋 Did you manage with the configuration? I would like to update that Descope is now providing a page that hosts the login flow. It can be used by our customers that dont want to host it by themself. The documentation will arrive soon but since i saw you looked for it you can give it a try. Just set this page URL under the OIDC
Flow hosting URL
and use your
projectID
. Also make sure this method is enabled. https://auth.descope.io/PROJECT_ID?flow=sign-up-or-in you can use different flows if you’d like. just change the sign-up-or-in with the flow you want. Feel free to reach if any assistance is needed 👍
c
@rapid-doctor-25622 thank you. To be honest i gave up, but trying again now.
👍 1
ok. upgrade to @auth/core 0.9.0 have this in my hooks.server.js file
Copy code
import { SvelteKitAuth } from "@auth/sveltekit";
import descope from "@auth/core/providers/descope"
import type { Handle } from "@sveltejs/kit";
import { AUTH_SECRET  } from "$env/static/private";

export const handle = SvelteKitAuth({
providers: [
  descope({
    issuer: "<https://api.descope.com/P2RLA9Bz8Z6brrqPZN8X9e42CAfC>",
    authorization: "<https://auth.descope.io/P2RLA9Bz8Z6brrqPZN8X9e42CAfC?flow=sign-up-or-in>",
    clientId: "P2RLA9Bz8Z6brrqPZN8X9e42CAfC",
    clientSecret: "SECRET"
  })
],
})
without the issuer and authorization i get the following error Provider "descope" is missing both
issuer
and
authorization
endpoint config. with them , i get redirected to descope and get my flow page.. however when it gors bck thru the callback it fails with http://localhost:5173/auth/error?error=CallbackRouteError and
Copy code
[auth][error][CallbackRouteError]: Read more at <https://errors.authjs.dev#callbackrouteerror>
[auth][cause]: OperationProcessingError: no authorization code in "callbackParameters"
r
Hi @clever-laptop-72507, The
authorization
should be taken automatically from your
.well-known
configuration (https://api.descope.com/P2RLA9Bz8Z6brrqPZN8X9e42CAfC/.well-known/openid-configuration). So you should be able to work without configuring it. if it doesn’t work for some reason you can set it manually to https://api.descope.com/oauth2/v1/authorize as set in your
.well-knwon
configuration