Hello, I am trying to implement social login (google).... async function googleSignInClicked() { ...
u

.qwertin

almost 2 years ago
Hello, I am trying to implement social login (google).... async function googleSignInClicked() { try { const authUrl = await getAuthorisationURLWithQueryParamsAndSetState({ thirdPartyId: "google", // This is where Google should redirect the user back after login or error. // This URL goes on the Google's dashboard as well. frontendRedirectURI: "http://localhost:8100/auth/callback/google", }); /* Example value of authUrl: https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&access_type=offline&include_granted_scopes=true&response_type=code&client_id=1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com&state=5a489996a28cafc83ddff&redirect_uri=https%3A%2F%2Fsupertokens.io%2Fdev%2Foauth%2Fredirect-to-app&flowName=GeneralOAuthFlow */ // we redirect the user to google for auth. window.location.assign(authUrl); } catch (err: any) { if (err.isSuperTokensGeneralError === true) { // this may be a custom error message sent from the API by you. window.alert(err.message); } else { window.alert("Oops! Something went wrong."); } } } return { state, signUpClicked, signInClicked, googleSignInClicked }; }, }); and I get this error TS2345: Argument of type '{ thirdPartyId: string; frontendRedirectURI: string; }' is not assignable to parameter of type '{ providerId: string; authorisationURL: string; userContext?: any; providerClientId?: string | undefined; options?: RecipeFunctionOptions | undefined; }'.Object literal may only specify known properties, and 'thirdPartyId' does not exist in type '{ providerId: string; authorisationURL: string; userContext?: any; providerClientId?: string | undefined; options?: RecipeFunctionOptions | undefined; }'. What I am doing wrong ?
Hey there, I'm using supertokens in my NestJS app. I'm looking to have 2 different auth strategies, ...
g

gp01683

about 2 years ago
Hey there, I'm using supertokens in my NestJS app. I'm looking to have 2 different auth strategies, one for admin users and one for nomal users. I would like to have 2 different routes and 2 different supertokens service to I can customize sign in / signup options on both independently. Here's what I got at the moment: My abstracted identity module, following the supertokens doc:
export class IdentityAndAccessModule implements NestModule, OnModuleInit {
  ...

  static forRoot({ connectionURI, apiKey, appInfo, caslFactory }) {
    const providers: Provider[] = [
     ...
      {
        useValue: {
          appInfo,
          connectionURI,
          apiKey,
        },
        provide: ConfigInjectionToken,
      },
      SupertokensService,
      PrismaService,
    ];

    return {
      module: IdentityAndAccessModule,
      providers: providers,
      exports: providers,
    };
  }

...
}
Then my 2 auth modules, one for normal users and one for admin:
@Module({
  imports: [
    PrismaModule,
    // TODO: config
    IdentityAndAccessModule.forRoot({
      connectionURI: 'http://localhost:3567',
      appInfo: {
        appName: 'WC APP',
        apiDomain: 'http://localhost:3001',
        websiteDomain: 'http://localhost:3000',
        apiBasePath: '/auth',
        websiteBasePath: '/auth',
      },
      caslFactory: AppCaslFactory,
    }),
  ],
  providers: [AuthService, ...oauthProviders],
  exports: [AuthService, IdentityAndAccessModule],
  controllers: [],
})
export class CustomerAuthModule {}
and another one identical but using /admin/auth as base path for both API and website. My problem is that the first module registered in app.module.ts, will be available but not the other one. So /auth/signin works but /admin/auth/signin always return 404. Any idea? I guess it comes from my module being setup as singleton but can't find any way to have multiple instances using its own config