|
1 | 1 | import { env } from "@/env"; |
2 | | -import type { OAuth2Config, OAuthUserConfig } from "@auth/core/providers"; |
3 | 2 | import { db } from "@/server/db"; |
4 | 3 |
|
| 4 | +import type { OAuth2Config, OAuthUserConfig } from "next-auth/providers"; |
| 5 | + |
5 | 6 | export interface EtsyProfile { |
6 | | - user_id: number; // The numeric ID of a user. Also a valid shop ID. |
7 | | - primary_email?: string | null; // The user's primary email address (nullable). |
8 | | - first_name?: string | null; // The user's first name (nullable). |
9 | | - last_name?: string | null; // The user's last name (nullable). |
10 | | - image_url_75x75?: string | null; // The user's avatar URL (nullable). |
| 7 | + user_id: number; |
| 8 | + primary_email?: string | null; |
| 9 | + first_name?: string | null; |
| 10 | + last_name?: string | null; |
| 11 | + image_url_75x75?: string | null; |
11 | 12 | } |
12 | 13 |
|
13 | 14 | export default function EtsyProvider<P extends EtsyProfile>( |
@@ -48,9 +49,7 @@ export default function EtsyProvider<P extends EtsyProfile>( |
48 | 49 | }, |
49 | 50 | ); |
50 | 51 |
|
51 | | - const user = (await response.json()) as EtsyProfile; |
52 | | - |
53 | | - return user; |
| 52 | + return (await response.json()) as EtsyProfile; |
54 | 53 | }, |
55 | 54 | }, |
56 | 55 | profile(profile) { |
@@ -81,7 +80,13 @@ export async function refreshEtsyAccessToken( |
81 | 80 | if (!response.ok) { |
82 | 81 | throw new Error("Failed to refresh Etsy access token"); |
83 | 82 | } |
84 | | - const tokens = await response.json(); |
| 83 | + const tokens = (await response.json()) as { |
| 84 | + access_token: string; |
| 85 | + refresh_token: string; |
| 86 | + scope: string; |
| 87 | + token_type: string; |
| 88 | + expires_at: number; |
| 89 | + }; |
85 | 90 |
|
86 | 91 | await db.account.update({ |
87 | 92 | where: { |
|
0 commit comments