Skip to content

Commit

Permalink
Add Twitch OIDC Provider
Browse files Browse the repository at this point in the history
  • Loading branch information
biswassri authored and sberyozkin committed Jul 20, 2023
1 parent 35c1ca2 commit 3d975b2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,8 @@ public static enum Provider {
GOOGLE,
MICROSOFT,
SPOTIFY,
TWITTER
TWITTER,
TWITCH
}

public Optional<Provider> getProvider() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public static OidcTenantConfig provider(OidcTenantConfig.Provider provider) {
return spotify();
} else if (OidcTenantConfig.Provider.TWITTER == provider) {
return twitter();
} else if (OidcTenantConfig.Provider.TWITCH == provider) {
return twitch();
}
return null;
}
Expand Down Expand Up @@ -126,4 +128,22 @@ private static OidcTenantConfig spotify() {

return ret;
}

private static OidcTenantConfig twitch() {
// Ref https://dev.twitch.tv/docs/authentication/getting-tokens-oidc/#oidc-authorization-code-grant-flow

OidcTenantConfig ret = new OidcTenantConfig();
ret.setDiscoveryEnabled(true);
ret.setAuthServerUrl("https://id.twitch.tv/oauth2/");
ret.setAuthorizationPath("authorize");
ret.setTokenPath("token");
ret.setUserInfoPath("https://id.twitch.tv/oauth2/userinfo");
ret.setApplicationType(OidcTenantConfig.ApplicationType.WEB_APP);
ret.getAuthentication().setScopes(List.of("openid"));
ret.setAuthServerUrl("https://id.twitch.tv/oauth2/");
ret.setAuthorizationPath("authorize");
ret.getAuthentication().setIdTokenRequired(true);

return ret;
}
}

0 comments on commit 3d975b2

Please sign in to comment.