twitchProvider function

Implementation

OAuthProvider<TwitchProfile> twitchProvider(TwitchProviderOptions options) {
  return OAuthProvider<TwitchProfile>(
    id: 'twitch',
    name: 'Twitch',
    type: AuthProviderType.oidc,
    clientId: options.clientId,
    clientSecret: options.clientSecret,
    authorizationEndpoint: Uri.parse('https://id.twitch.tv/oauth2/authorize'),
    tokenEndpoint: Uri.parse('https://id.twitch.tv/oauth2/token'),
    userInfoEndpoint: Uri.parse('https://id.twitch.tv/oauth2/userinfo'),
    redirectUri: options.redirectUri,
    scopes: options.scopes,
    useBasicAuth: false, // Twitch uses client_secret_post
    profileParser: TwitchProfile.fromJson,
    profileSerializer: (profile) => profile.toJson(),
    profile: (profile) {
      return AuthUser(
        id: profile.sub,
        name: profile.preferredUsername,
        email: profile.email,
        image: profile.picture,
        attributes: profile.toJson(),
      );
    },
  );
}