小编Aks*_*hay的帖子

如何使用从 createEntityAdapter 生成的 selectById 选择器

redux-toolkit 网站上的所有示例都显示了selectIds或 的用法selectAll。使用它们中的任何一个都很简单。我有一个redux-slice我要出口的地方

export const {
  selectById: selectUserById,
  selectIds: selectUserIds,
  selectEntities: selectUserEntities,
  selectAll: selectAllUsers,
  selectTotal: selectTotalUsers
} = usersAdapter.getSelectors(state => state.users)
Run Code Online (Sandbox Code Playgroud)

然后我在我的组件中导入选择器并使用类似

const valueIAmInterestedIn = useSelector(selectUserIds)
Run Code Online (Sandbox Code Playgroud)

我对与selectUserById.

reactjs redux react-redux redux-toolkit

3
推荐指数
1
解决办法
3471
查看次数

如何使用服务帐户访问 GSuite 电子邮件帐户的 GMAIL API

我希望我的服务帐户能够模拟 GSuite 中的用户之一。我有

  • 通过 GCP 创建项目
  • 在项目中启用GMail API
  • 向该项目添加了一个服务帐户
  • domain-wide delegation在服务帐户设置中启用GCP
  • 通过 Google 管理控制台在高级设置中API Client添加了service account idGSuite

在浏览文档(java)时,我看到了这个

GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream("MyProject-1234.json"))
    .createScoped(Collections.singleton(SQLAdminScopes.SQLSERVICE_ADMIN))
    .createDelegated("user@example.com");
Run Code Online (Sandbox Code Playgroud)

在这里,他们指定服务帐户应模拟哪个用户。这段代码是java中的。我需要在nodejs 中完成同样的事情。

在查看nodejs-clientfor的文档时googleapis,我发现了这一点:

const {google} = require('googleapis');

const auth = new google.auth.GoogleAuth({
  keyFile: '/path/to/your-secret-key.json',
  scopes: ['https://www.googleapis.com/auth/cloud-platform'],
});
Run Code Online (Sandbox Code Playgroud)

const {google} = require('googleapis');

const oauth2Client = new google.auth.OAuth2(
  YOUR_CLIENT_ID,
  YOUR_CLIENT_SECRET,
  YOUR_REDIRECT_URL
);

// set auth as a global default
google.options({
  auth: oauth2Client
});
Run Code Online (Sandbox Code Playgroud)

GoogleAuth和这里有什么区别OAuth2 …

node.js google-api-client google-api-nodejs-client gmail-api

3
推荐指数
1
解决办法
3883
查看次数