diff --git a/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/auth/GoogleAuthResource.scala b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/auth/GoogleAuthResource.scala index f93a516ea0..175a62fc2a 100644 --- a/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/auth/GoogleAuthResource.scala +++ b/core/amber/src/main/scala/edu/uci/ics/texera/web/resource/auth/GoogleAuthResource.scala @@ -37,10 +37,7 @@ class GoogleAuthResource { @GET @Path("/clientid") - @Produces(Array(MediaType.APPLICATION_JSON)) - def getClientId: Map[String, String] = { - Map("clientId" -> clientId) - } + def getClientId: String = clientId @POST @Consumes(Array(MediaType.TEXT_PLAIN)) diff --git a/core/gui/src/app/app.module.ts b/core/gui/src/app/app.module.ts index 4e44f78bf1..5bd4209777 100644 --- a/core/gui/src/app/app.module.ts +++ b/core/gui/src/app/app.module.ts @@ -146,17 +146,6 @@ import { lastValueFrom } from "rxjs"; registerLocaleData(en); -const socialConfigFactory = (googleAuthService: GoogleAuthService, userService: UserService) => { - return lastValueFrom(googleAuthService.getClientId()).then(response => ({ - providers: [ - { - id: GoogleLoginProvider.PROVIDER_ID, - provider: new GoogleLoginProvider(response?.clientId || "", {oneTapEnabled: !userService.isLogin()}), - }, - ] - })) as Promise; -}; - @NgModule({ declarations: [ AdminGmailComponent, @@ -320,7 +309,16 @@ const socialConfigFactory = (googleAuthService: GoogleAuthService, userService: }, { provide: "SocialAuthServiceConfig", - useFactory: socialConfigFactory, + useFactory: (googleAuthService: GoogleAuthService, userService: UserService) => { + return lastValueFrom(googleAuthService.getClientId()).then(clientId => ({ + providers: [ + { + id: GoogleLoginProvider.PROVIDER_ID, + provider: new GoogleLoginProvider(clientId, {oneTapEnabled: !userService.isLogin()}), + }, + ] + })) as Promise; + }, deps: [GoogleAuthService, UserService], }, ], diff --git a/core/gui/src/app/common/service/user/google-auth.service.ts b/core/gui/src/app/common/service/user/google-auth.service.ts index f68a782915..3edb1b03bc 100644 --- a/core/gui/src/app/common/service/user/google-auth.service.ts +++ b/core/gui/src/app/common/service/user/google-auth.service.ts @@ -9,7 +9,7 @@ import { AppSettings } from "../../app-setting"; export class GoogleAuthService { constructor(private http: HttpClient) {} - getClientId(): Observable<{ clientId: string }> { - return this.http.get<{ clientId: string }>(`${AppSettings.getApiEndpoint()}/auth/google/clientid`); + getClientId(): Observable { + return this.http.get(`${AppSettings.getApiEndpoint()}/auth/google/clientid`, { responseType: "text" }) } }