Hello, For my custom application, I am using Desc...
# ask-a-descoper
h
Hello, For my custom application, I am using Descope for authenticating my users. My application works on my laptop but doesn't work on my colleague's laptop which is new windows laptop. The application opens up the browser, requests for a token from api.descope.com for the given project ID and user credentials. The Descope backend does send 'Authentication successful message on both laptops and a session token. However, the call to session validation using client.Auth.ValidateSessionWithToken(context.Background() fails on my colleague's laptop while it succeeds on mine. The error received on my colleague's laptop is: ERR Failed to do user auth error="session token invalid: [G030002] Invalid token Has anybody seen something like before? I am out of ideas to try. I will appreciate any pointers to what could be going wrong. Thank you,
r
Hi @Hari Based on your Go code reference to
ValidateSessionWithToken
, here are key validation points to check: Verify
aud
claim validation: The session token should include the correct audience claim. Use the proper validation method with your Project ID:
Copy code
// Validate session with aud claim
authorized, userToken, err := descopeClient.Auth.ValidateSessionWithToken(ctx, sessionToken, "__ProjectID__")
if (err != nil){
  fmt.Println("Could not validate user session: ", err)
} else {
  fmt.Println("Successfully validated user session: ", userToken)
}
Check token extraction: Ensure the session token is properly extracted from the Authorization header. The token format and extraction method should be identical on both laptops. Verify client configuration: Confirm both laptops use the same Descope client setup:
Copy code
descopeClient, err := client.NewWithConfig(&client.Config{ProjectID:"__ProjectID__"})
if err != nil {
    log.Println("failed to initialize: " + err.Error())
}
Common causes for G030002 "Invalid token" error: The error suggests the token itself is malformed or doesn't match the expected validation parameters rather than being expired. Reference docs: https://docs.descope.com/getting-started/go https://docs.descope.com/authorization/session-management/session-validation/backend
h
Hi @Rahul Rijhwani, thanks for the reply. In my case the same binary/exe used on both laptops. So the descope client setup is same , project ID also the same. and to Validate session with aud claim, three is no method/function that takes 3rd argument "ProjectId".
@Rahul Rijhwani - issue seems to be windows laptop’s system clock was out of sync because the Windows Time service (w32time) wasn’t running.. FYI.