Greetings, I’m attempting to implement Twitch OIDC authentication with a web app, using VueJS/Typescript/oidc-client on the frontend and ASP.Net Core JWT auth on the backend. The auth takes place and works correctly, but the ID Token(JWT token) expires after a short period of time and doesn’t renew(the backend starts returning 401 after about 5-10 minutes).
I believe the issue is the silent renew in oidc-client isn’t functioning correctly. It appears to rely on iframes for the silent renewal and despite the correct URI’s being placed in my Twitch client configuration on the Twitch developer platform, I am receiving an IFrame error(Refused to display 'https://www.twitch.tv/login...' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
).
I was considering using Refresh Tokens, but from what I understand they only apply to Access Tokens, not ID tokens.
Is there some method in which I can either get the silent renew to function correctly, or authorize the backend API using OIDC Access Tokens/Refresh Tokens(assuming this is wise)?
For further reference, here is my oidc-client configuration(with client details removed of course):
var mgr = new Oidc.UserManager({
userStore: new Oidc.WebStorageStateStore({store: localStorage}),
authority: "https://id.twitch.tv/oauth2",
client_id: "...",
redirect_uri: url + "callback",
response_type: "id_token token",
scope: "openid user:read:email",
post_logout_redirect_uri: url,
silent_redirect_uri: url + "silent-renew.html",
accessTokenExpiringNotificationTime: 10,
automaticSilentRenew: true, // Tried turnin this off and using addAccessTokenExpiring event
filterProtocolClaims: true,
loadUserInfo: true,
revokeAccessTokenOnSignout: true,
monitorSession: false // Tried with/without this
});
And here is the ASP configuration:
services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = Configuration.GetSection("Auth").GetValue<string>("Authority");
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidIssuer = Configuration.GetSection("Auth").GetValue<string>("Authority"),
ValidateAudience = true,
ValidAudience = Configuration.GetSection("Auth").GetValue<string>("Audience"),
ValidateLifetime = true,
};
});
Thanks.