-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Failed obtaining twitch user profile" when using Twitch provider #460
Comments
It appears the bug was on Twitch's end. Closing. |
I have the same issue, what is happening? |
I might've been mistaken to close this issue, since it's still happening. This bug occurs because @hapi/bell is trying to get the OAuth profile details of the user trying to connect and fails. And sure enough, it wasn't a bug, but a planned security measure, as seen in Twitch's dev forums :
The Client-ID header is required in all requests to their new Helix API; which is used for OAuth. There is however, the possibility of using a custom provider with Twitch's provider settings. (which can be found here). I got mine working using this code, keeping in mind that you need to replace all of the secrets with yours. server.auth.strategy("twitch", "bell", {
// twitch implementation is broken in @hapi/bell, Client-ID header must be included in each request
provider: {
name: "twitch",
protocol: "oauth2",
useParamsAuth: true,
auth: "https://id.twitch.tv/oauth2/authorize",
token: "https://id.twitch.tv/oauth2/token",
headers: {
"Client-ID": process.env.TWITCH_CLIENT_ID,
},
scope: ["user:read:email"],
scopeSeparator: " ",
profile: async function (credentials, params, get) {
const profileResponse = await get(
"https://api.twitch.tv/helix/users",
{}
);
credentials.profile = profileResponse.data[0];
},
},
password: process.env.COOKIE_PASSWORD,
clientId: process.env.TWITCH_CLIENT_ID,
clientSecret: process.env.TWITCH_CLIENT_SECRET,
isSecure: process.env.NODE_ENV === "production",
}); This is a pretty bad quick fix to get it working. Reopening this issue since it's now an implementation error and not Twitch's fault. |
Oh thank you so much, I was reading for hours the reason for this problem and I didn't know that I could customize my provider |
Support plan
Context
What are you trying to achieve or the steps to reproduce?
When trying to authenticate a route using @hapi/bell on @hapi/hapi, instead of correctly authenticating the user, @hapi/bell returns an error: Failed obtaining twitch user profile.
To easily replicate this, you can setup the example from this repository and test the endpoint.
It will crash with the same error.
What was the result you got?
An error saying "Failed obtaining twitch user profile."
What result did you expect?
Authentication is successful.
The text was updated successfully, but these errors were encountered: