Updated list of commands to v4.3. Added groups & permissions. Added connections. Updated redemptions and actions to v4.3.
This commit is contained in:
@ -15,22 +15,22 @@ export async function GET(req: Request) {
|
||||
|
||||
// Verify state against user id in user table.
|
||||
const user = await db.user.findFirst({
|
||||
where: {
|
||||
id: state
|
||||
}
|
||||
where: {
|
||||
id: state
|
||||
}
|
||||
})
|
||||
|
||||
if (!user) {
|
||||
return new NextResponse("Bad Request", { status: 400 });
|
||||
return new NextResponse("Bad Request", { status: 400 });
|
||||
}
|
||||
|
||||
// Post to https://id.twitch.tv/oauth2/token
|
||||
const token: { access_token:string, expires_in:number, refresh_token:string, token_type:string, scope:string[] } = (await axios.post("https://id.twitch.tv/oauth2/token", {
|
||||
const token: { access_token: string, expires_in: number, refresh_token: string, token_type: string, scope: string[] } = (await axios.post("https://id.twitch.tv/oauth2/token", {
|
||||
client_id: process.env.TWITCH_BOT_CLIENT_ID,
|
||||
client_secret: process.env.TWITCH_BOT_CLIENT_SECRET,
|
||||
code: code,
|
||||
grant_type: "authorization_code",
|
||||
redirect_uri: "https://hermes.goblincaves.com/api/account/authorize"
|
||||
redirect_uri: "https://tomtospeech.com/api/account/authorize"
|
||||
})).data
|
||||
|
||||
// Fetch values from token.
|
||||
@ -49,17 +49,17 @@ export async function GET(req: Request) {
|
||||
const broadcasterId = info.data.data[0]['id']
|
||||
|
||||
await db.twitchConnection.create({
|
||||
data: {
|
||||
broadcasterId: broadcasterId,
|
||||
accessToken: access_token,
|
||||
refreshToken: refresh_token,
|
||||
userId: state
|
||||
}
|
||||
data: {
|
||||
broadcasterId: broadcasterId,
|
||||
accessToken: access_token,
|
||||
refreshToken: refresh_token,
|
||||
userId: state
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
return new NextResponse("", { status: 200 });
|
||||
} catch (error) {
|
||||
console.log("[ACCOUNT]", error);
|
||||
console.log("[ACCOUNT/AUTHORIZE]", error);
|
||||
return new NextResponse("Internal Error", { status: 500 });
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user