You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey! I don't know where to post this, as it could be either an issue with this library, a remix-auth issue, or just the way my OAuth provider is handling the request and I'm completely new to Remix.
I also don't know how to provide reproduction steps, since it might be specific to this provider.
So basically what is happening, is that my callbackURL is being completely ignored, and I'm getting redirected back to the login route. BUT the first login with my provider is working, since it redirects to the provider's website and asks for consent. But once we have consent, the logins after that are "instant" (no consent asked).
But this "instant" functionality is making my callbackURL be skipped entirely.
Here's the logs when no consent is given, and the flow is normal:
GET / 200 - - 12.049 ms
OAuth2Strategy Request URL http://localhost:4200/api/auth/login +0ms
OAuth2Strategy Callback URL URL {
href: 'http://localhost:4200/api/auth/callback',
origin: 'http://localhost:4200',
protocol: 'http:',
username: '',
password: '',
host: 'localhost:4200',
hostname: 'localhost',
port: '4200',
pathname: '/api/auth/callback',
search: '',
searchParams: URLSearchParams {},
hash: ''
} +0ms
OAuth2Strategy Redirecting to callback URL +2ms
OAuth2Strategy State 9b7048dd-bbf8-4730-a8b6-d065f40759f0 +0ms
POST /api/auth/login?_data=routes%2Fapi%2Fauth%2Flogin 204 - - 9.372 ms
OAuth2Strategy Request URL http://localhost:4200/api/auth/callback?code=def50200470... +3s
OAuth2Strategy Callback URL URL {
href: 'http://localhost:4200/api/auth/callback',
origin: 'http://localhost:4200',
protocol: 'http:',
username: '',
password: '',
host: 'localhost:4200',
hostname: 'localhost',
port: '4200',
pathname: '/api/auth/callback',
search: '',
searchParams: URLSearchParams {},
hash: ''
} +1ms
OAuth2Strategy State from URL 9b7048dd-bbf8-4730-a8b6-d065f40759f0 +1ms
OAuth2Strategy State from session 9b7048dd-bbf8-4730-a8b6-d065f40759f0 +0ms
OAuth2Strategy State is valid +0ms
Fetching user...
Fetched user hallowatcher
TODO create or fetch user { provider: 'osu', id: '1874761', username: 'hallowatcher' }
OAuth2Strategy User authenticated +1s
GET /api/auth/callback?code=def502004... 302 - - 1291.926 ms
Homepage User { provider: 'osu', id: '1874761', username: 'hallowatcher' }
GET / 200 - - 9.630 ms
Here's the logs once consent has been given, and the OAuth provider instantly redirects back:
GET / 200 - - 1651.086 ms
OAuth2Strategy Request URL http://localhost:4200/api/auth/login +0ms
OAuth2Strategy Callback URL URL {
href: 'http://localhost:4200/api/auth/callback',
origin: 'http://localhost:4200',
protocol: 'http:',
username: '',
password: '',
host: 'localhost:4200',
hostname: 'localhost',
port: '4200',
pathname: '/api/auth/callback',
search: '',
searchParams: URLSearchParams {},
hash: ''
} +1ms
OAuth2Strategy Redirecting to callback URL +2ms
OAuth2Strategy State 49fa4df2-6721-49d3-847a-b4507d1ac04d +0ms
POST /api/auth/login?_data=routes%2Fapi%2Fauth%2Flogin 204 - - 9.126 ms
Error: You made a GET request to http://localhost:4200/api/auth/login but did not provide a default component or `loader` for route "routes/api/auth/login", so there is no way to handle the request.
GET /api/auth/login 500 - - 7.771 ms
And here's the network tab for that:
As you can see, the authorize and callback requests have no statuses, so my browser tries to GET the login route which doesn't exist, only POST exists for that. And adding a redirect from the login route also does not help, it simply redirects and the user is not logged in in the end. But it does allow the flow to complete, here's the logs with a redirect from the login page:
GET /?_data=root 200 - - 4.842 ms
OAuth2Strategy Request URL http://localhost:4200/api/auth/login +9m
OAuth2Strategy Callback URL URL {
href: 'http://localhost:4200/api/auth/callback',
origin: 'http://localhost:4200',
protocol: 'http:',
username: '',
password: '',
host: 'localhost:4200',
hostname: 'localhost',
port: '4200',
pathname: '/api/auth/callback',
search: '',
searchParams: URLSearchParams {},
hash: ''
} +1ms
OAuth2Strategy Redirecting to callback URL +0ms
OAuth2Strategy State 64d7c39a-7d51-40c7-98d5-9772e64e84e6 +1ms
POST /api/auth/login?_data=routes%2Fapi%2Fauth%2Flogin 204 - - 6.430 ms
OAuth2Strategy Request URL http://localhost:4200/api/auth/callback?code=def5020027... +547ms
OAuth2Strategy Callback URL URL {
href: 'http://localhost:4200/api/auth/callback',
origin: 'http://localhost:4200',
protocol: 'http:',
username: '',
password: '',
host: 'localhost:4200',
hostname: 'localhost',
port: '4200',
pathname: '/api/auth/callback',
search: '',
searchParams: URLSearchParams {},
hash: ''
} +1ms
OAuth2Strategy State from URL 64d7c39a-7d51-40c7-98d5-9772e64e84e6 +0ms
OAuth2Strategy State from session 64d7c39a-7d51-40c7-98d5-9772e64e84e6 +1ms
OAuth2Strategy State is valid +0ms
GET /api/auth/callback?code=def5020027f3... - - - - ms
GET /api/auth/login 302 - - 4.362 ms
Homepage User null
GET / 200 - - 11.102 ms
Fetching user...
Fetched user hallowatcher
TODO create or fetch user { provider: 'osu', id: '1874761', username: 'hallowatcher' }
OAuth2Strategy User authenticated +1s
As you can see, the OAuth strategy actually completes in this case, but it is not awaited. The user is already on the page for a second or two before OAuth2Strategy User authenticated is shown.
Here's my business logic for reference:
app/src/Layout.tsx
...
<Formaction="/api/auth/login" method="post"><Buttontype="submit">
Log in
</Button></Form>
...
export let sessionStorage = createCookieSessionStorage({
cookie: {
name: '_session',
sameSite: 'lax',
path: '/',
httpOnly: true,
secrets: ['s3cr3t'], // TODO replace with actual secret
secure: process.env.NODE_ENV === 'production',
},
});
// you can also export the methods individually for your own usage
export let { getSession, commitSession, destroySession } = sessionStorage;
I know this is a lot to look at, and I'm not expecting much. I'm currently checking out Remix and seeing if it fits my needs in order to change from Angular + NestJS. Thanks!
The text was updated successfully, but these errors were encountered:
After a bit further investigation and debugging, I found that the problem lies in the fetchAccessToken function. Once the fetch gets triggered, for some reason we receive a redirect on the browser, which gets followed even though the endpoint hasn't finished running.
Hey! I don't know where to post this, as it could be either an issue with this library, a
remix-auth
issue, or just the way my OAuth provider is handling the request and I'm completely new to Remix.I also don't know how to provide reproduction steps, since it might be specific to this provider.
So basically what is happening, is that my
callbackURL
is being completely ignored, and I'm getting redirected back to the login route. BUT the first login with my provider is working, since it redirects to the provider's website and asks for consent. But once we have consent, the logins after that are "instant" (no consent asked).But this "instant" functionality is making my
callbackURL
be skipped entirely.Here's the logs when no consent is given, and the flow is normal:
Here's the logs once consent has been given, and the OAuth provider instantly redirects back:
And here's the network tab for that:
As you can see, the authorize and callback requests have no statuses, so my browser tries to GET the login route which doesn't exist, only POST exists for that. And adding a redirect from the login route also does not help, it simply redirects and the user is not logged in in the end. But it does allow the flow to complete, here's the logs with a redirect from the login page:
As you can see, the OAuth strategy actually completes in this case, but it is not awaited. The user is already on the page for a second or two before
OAuth2Strategy User authenticated
is shown.Here's my business logic for reference:
app/src/Layout.tsx
app/routes/api/auth/login.ts
app/routes/api/auth/callback.ts
app/services/osu.strategy.ts
app/services/osu.strategy.ts
app/services/session.server.ts
I know this is a lot to look at, and I'm not expecting much. I'm currently checking out Remix and seeing if it fits my needs in order to change from Angular + NestJS. Thanks!
The text was updated successfully, but these errors were encountered: