I’m currently trying to create a custom reward using the helix api within my backend.
The Frontend already sends an Authorization Header with the token provided by onAuthorized. But what token do I send to the helix api? I’ve tried several keys from the twitch console, tried the token delivered by onAuthorized itself, but so far I only got error: "Unauthorized", status: 401, message: "Invalid OAuth token". Do I need to create the token myself using jwt?
Your assumption that a JWT is an OAuth Token is incorrect - JWTs only work as authentication for the Endpoints under the /extensions/ path in the API - not Helix. (See also what is mentioned under Authentication for each endpoint here vs. here)
You’ll have to send the Broadcaster through an additional OAuth Flow to receive the required scopes on a User Access Token.
I took a look at the different OAuth Flows and tried to implement the “OAuth client credentials flow” to handle everything serverside. Thats how I try to retrieve the token:
Not a server to server token.
As server to server tokens (simply) do not have access to priviledged/scoped data as they don’t represent a user.
You can also see in the documentation for the endpoint you are trying to call
Authentication
Query parameter broadcaster_id must match the user_id in the User Access token
Authorization
Requires OAuth Scope: channel:read:redemptions