@@ -22,8 +22,8 @@ const AIRBYTE_WIDGET_URL = `${BASE_URL}/v1/embedded/widget_token`;
22
22
const AIRBYTE_ACCESS_TOKEN_URL = `${ BASE_URL } /v1/applications/token` ;
23
23
const CLIENT_ID = process . env . NEXT_PUBLIC_CLIENT_ID ;
24
24
const CLIENT_SECRET = process . env . NEXT_PUBLIC_CLIENT_SECRET ;
25
- const WORKSPACE_ID = process . env . NEXT_PUBLIC_WORKSPACE_ID ;
26
-
25
+ const EXTERNAL_ID = process . env . NEXT_PUBLIC_EXTERNAL_USER_ID ;
26
+ const ORGANIZATION_ID = process . env . NEXT_PUBLIC_ORGANIZATION_ID ;
27
27
export async function GET ( request : NextRequest ) {
28
28
try {
29
29
const referer = request . headers . get ( "referer" ) ;
@@ -43,10 +43,14 @@ export async function GET(request: NextRequest) {
43
43
return NextResponse . json ( { error : "Missing CLIENT_SECRET environment variable" } , { status : 500 } ) ;
44
44
}
45
45
46
- if ( ! WORKSPACE_ID ) {
46
+ if ( ! EXTERNAL_ID ) {
47
47
return NextResponse . json ( { error : "Missing WORKSPACE_ID environment variable" } , { status : 500 } ) ;
48
48
}
49
49
50
+ if ( ! ORGANIZATION_ID ) {
51
+ return NextResponse . json ( { error : "Missing ORGANIZATION_ID environment variable" } , { status : 500 } ) ;
52
+ }
53
+
50
54
// Get access token
51
55
const accessTokenBody = JSON . stringify ( {
52
56
client_id : CLIENT_ID ,
@@ -96,7 +100,8 @@ export async function GET(request: NextRequest) {
96
100
Authorization : `Bearer ${ accessToken } ` ,
97
101
} ,
98
102
body : JSON . stringify ( {
99
- workspaceId : WORKSPACE_ID ,
103
+ externalUserId : EXTERNAL_ID ,
104
+ organizationId : ORGANIZATION_ID ,
100
105
allowedOrigin : origin ,
101
106
} ) ,
102
107
} ) ;
@@ -119,7 +124,7 @@ export async function GET(request: NextRequest) {
119
124
const tokenUrl = new URL ( decodedToken . widgetUrl ) ;
120
125
121
126
const newToken = {
122
- widgetUrl : `https://localhost:3000 ${ tokenUrl . pathname } ?${ tokenUrl . searchParams . toString ( ) } ` ,
127
+ widgetUrl : `${ process . env . NEXT_PUBLIC_WEBAPP_URL } ${ tokenUrl . pathname } ?${ tokenUrl . searchParams . toString ( ) } ` ,
123
128
token : decodedToken . token ,
124
129
} ;
125
130
debugLog ( "New token:" , newToken ) ;
0 commit comments