You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kick.com is a very fast-growing platform, so I think many users will need this integration.
Proposal
Custom provider:
import{OAuthConfig}from'next-auth/providers';importfetchfrom'node-fetch';typeKickUserInfo={data:
|{user_id: number;name: string;email: string;profile_picture: string;}[]|null;message: string;};asyncfunctiongetKickUserInfo(accessToken: string){consturl='https://api.kick.com/public/v1/users';constres=awaitfetch(url,{headers: {Authorization: `Bearer ${accessToken}`,},});if(!res.ok){thrownewError('Failed to fetch user info from Kick API');}constjson=(awaitres.json())asKickUserInfo;constuserInfo=json.data?.[0];if(!userInfo){thrownewError('Cannot get user info details');}returnuserInfo;}exporttypeKickProfile={id: string;username: string;email: string;profile_picture: string;};exportfunctionKickProvider(options: {clientId: string;clientSecret: string;scope?: string;}): OAuthConfig<KickProfile>{const{
clientId,
clientSecret,
scope ='user:read channel:read chat:write events:subscribe',}=options;return{id: 'kick',name: 'Kick',type: 'oauth',
clientId,
clientSecret,client: {token_endpoint_auth_method: 'client_secret_post',},checks: ['state','pkce'],authorization: {url: 'https://id.kick.com/oauth/authorize',params: {response_type: 'code',client_id: clientId,redirect_uri: `${process.env.NEXTAUTH_URL}/api/auth/callback/kick`,
scope,code_challenge_method: 'S256',},},token: {url: 'https://id.kick.com/oauth/token',params: {grant_type: 'authorization_code',},},userinfo: {request: async(context)=>{const{tokens}=context;constaccess_token=tokens.access_token;if(!access_token){thrownewError("Missing 'access_token'");}constkickUserInfo=awaitgetKickUserInfo(access_token);constprofile: KickProfile={id: String(kickUserInfo.user_id),username: kickUserInfo.name,email: kickUserInfo.email,profile_picture:
kickUserInfo.profile_picture||// Fallback, you can use images from 1 to 6'https://kick.com/img/default-profile-pictures/default2.jpeg',};returnprofile;},},profile(profile){return{id: profile.id,name: profile.username,email: profile.email,image: profile.profile_picture,};},};}
Usage:
NextAuth(req,res,{providers: [KickProvider({clientId: process.env.KICK_CLIENT_IDasstring,clientSecret: process.env.KICK_CLIENT_SECRETasstring,}),],// rest of your code});
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Goals
Yesterday Kick.com realeased open api and OAuth2 integration. Until we get the official integration in Next auth I have prepared a custom provider.
https://docs.kick.com/getting-started/generating-tokens-oauth2-flow
Non-Goals
No response
Background
Kick.com is a very fast-growing platform, so I think many users will need this integration.
Proposal
Custom provider:
Usage:
Beta Was this translation helpful? Give feedback.
All reactions