MuleSoft Google日历连接器

时间:2015-10-15 18:22:31

标签: mule google-calendar-api mule-component

有没有办法用谷歌服务帐户验证Mule谷歌日历连接器,这样我每次都可以避免访问弹出窗口。

2 个答案:

答案 0 :(得分:0)

查看管理OAuth令牌,如果您创建处理这些持久性的对象存储,那么它将重用访问令牌,而不是每次重定向授权:https://docs.mulesoft.com/mule-user-guide/v/3.4/using-a-connector-to-access-an-oauth-api#managing-oauth-tokens-optional

答案 1 :(得分:0)

我找到了一个解决我问题的简单方法

    public void Auth() {
    try {
        httpTransport = GoogleNetHttpTransport.newTrustedTransport();
         credential = new GoogleCredential.Builder()
            .setTransport(httpTransport)
            .setJsonFactory(JSON_FACTORY)
            .setServiceAccountId(getConsumerKey())
            .setServiceAccountPrivateKeyFromP12File(new File(getConsumerSecret()))
            .setServiceAccountScopes(Arrays.asList(getScope())).build();

         client = new Calendar.Builder(
                    httpTransport, JSON_FACTORY, credential)
                    .setApplicationName(getApplicationName()).build();

    } 
    catch (Exception e) {

        e.printStackTrace();
    }
}

只需在退出的Google日历代码中包含上述功能,然后从代码中删除基于令牌的身份验证。 这将与谷歌的服务帐户完全一致。

由于

相关问题