workos / authkit-js

Vanilla JS AuthKit SDK
MIT License
7 stars 2 forks source link

authkit-js refresh token requests 400 #37

Open paulfalgout opened 2 weeks ago

paulfalgout commented 2 weeks ago

From the timeout https://github.com/workos/authkit-js/blob/cdef77b7c38479897d7ebc7e446c7d47dc69d9a4/src/create-client.ts#L159

Screenshot 2024-10-18 at 2 07 13 PM
cmatheson commented 2 weeks ago

hey @paulfalgout , could you give a bit more context? (how to reproduce, what type of environment, etc.).

paulfalgout commented 2 weeks ago

Our implementation of this library is here: https://github.com/RoundingWell/care-ops-frontend/blob/develop/src/js/auth/workos.js

Pretty sure if you

import { createClient } from '@workos-inc/authkit-js';
await createClient(clientId);

then wait the token expiration time + 1000 and you'll see that in the console.

geoffsoftledger commented 2 weeks ago

Having this same issue... Looks like this only happens when devMode={false}

southgate commented 2 weeks ago

@paulfalgout we need to do a better job with that error.

For security reasons, we rely on passing the refresh token in an http only cookie to the WorkOS API in production.

What’s likely happening is that you haven’t yet set up a custom domain, so some browsers are blocking your WorkOS session cookie as a 3rd party cookie (this is the reason we use the localstorage in development — we want to avoid that 3rd party cookie blocking).

paulfalgout commented 2 weeks ago

And then modify apiHostname in the createClientOptions like await createClient(clientId, { apiHostname: authenticationapi.com }); ?