首页 文章

您可以将相同的AWS用户池连接到React Native和React App吗?

提问于
浏览
1

我已经使用AWS Amplify(终端中的“放大添加auth”)使用我的React Native应用程序在AWS Cognito中创建用户池,但我不知道如何将同一个用户池连接到我的React App . 据我所知,Amplify Cli只提供了创建新资源的选项......有谁知道如何将它连接到已经存在/正在使用的用户池?

1 回答

  • 1

    您可以在任何框架中使用相同的池 . 确保传入正确的用户池配置 .

    // AppSync client instantiation
    const client = new AWSAppSyncClient({
      url: AppSync.graphqlEndpoint,
      region: AppSync.region,
      auth: {
        // IAM
        // type: AUTH_TYPE.AWS_IAM,
        // credentials: () => Auth.currentCredentials(),
    
        // COGNITO USER POOLS
        type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
        jwtToken: async () => (await Auth.currentSession()).getAcceessToken().getJwtToken(),
      },
    });
    

相关问题