[v2] Missing or invalid 'expires_in' field
After updating to v2 I'm getting a 500 - Internal Server Error on the callback with the following:
Unexpected Server Error
Error: Missing or invalid 'expires_in' field
I'm unsure if I'm missing something or need some additional configuration to upgrade to v2, but I think the problem might be related to https://github.com/sergiodxa/remix-auth-oauth2/pull/116.
Here's the options object and the cookie in case it's helpful:
const gitHubOptions: GitHubStrategyOptions = {
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
redirectURI: `${process.env.HOST}${"/auth/github/callback"}`,
scopes: ["user:email"],
};
const { protocol } = new URL(process.env.HOST);
export const cookie = createCookie("SESSION", {
httpOnly: protocol === "https:",
maxAge: Duration.fromObject({ days: 7 }).shiftTo("seconds").seconds,
path: "/",
sameSite: "lax",
secrets: ["xxxxx"],
secure: protocol === "https:",
});
Let me know if I can help in any way. I'll be happy to contribute to this library 🙂
Getting the same error, github no longer authenticates.
This comes back encoded in the _session cookie:
"__flash_auth:error__": {
"message": "Missing or invalid 'expires_in' field"
}
Maybe related to this also: https://github.com/sergiodxa/remix-auth-github/discussions/39
I ran into the same issue today and after diving deep into my node_modules (😅), I figured what is going on here.
GitHub doesn't provide the expires_in attribute when you didn't activate the "User-to-server token expiration" feature. This feature is not available in OAuth apps though.
Instead, you have to create a GitHub App and explicitly activate the "User-to-server token expiration" feature.
The latest version gives you the OAuth2Tokens object directly and you can read the expires_in handling possible missing field.