【问题标题】:App ID Custom Widget for a serverles SPA用于服务器 SPA 的 App ID 自定义小部件
【发布时间】:2018-01-03 14:24:49
【问题描述】:

如何为服务器安全的 SPA 应用程序创建自定义 IBM Cloud App ID 登录小部件(云目录)?

安全 SPA 应用程序将仅通过网关 API 使用 IBM Cloud Functions。

我是否只需要将https://github.com/ibm-cloud-security/appid-serversdk-nodejs 实现为云功能来自定义小部件并按我的意愿保持我的应用服务器?

我无法从文档https://console.bluemix.net/catalog/services/app-id 中找到线索

想法?

@Jarkko

【问题讨论】:

  • 您要使用 App ID 登录小部件吗?或者提供您自己的自定义 UI 来自己收集用户的凭据,然后使用 REST API 来使用那里的凭据获取令牌?

标签: ibm-cloud ibm-appid


【解决方案1】:

如果您不想使用 App ID 登录小部件,而是自己收集凭据并使用云函数中的 ROP REST API。你可以这样做:

let request = require('request');

// put your App ID credentials here (can be found in App ID console):
let credentials = {
    "version": 3,
    "clientId": "xxxxx",
    "secret": "xxxxx",
    "tenantId": "xxxxx",
    "oauthServerUrl": "https://appid-oauth.eu-gb.bluemix.net/oauth/v3/xxxxx",
    "profilesUrl": "https://appid-profiles.eu-gb.bluemix.net"
};


function main(params) {
    return new Promise(function (resolve, reject) {
        request({
            url: credentials.oauthServerUrl + '/token',
            method: 'POST',
            auth: {
                username: credentials.clientId,
                password: credentials.secret
            },
            form: {

                grant_type: "password",
                // replace with actual credentials:
                username: "aaa@bbb.com",
                password: "11111111"
            }
        }, function (error, response, body) {
            resolve(response);
            // handle errors...
        });
    })
}

在这种情况下,响应将是 App ID 访问令牌。

【讨论】:

  • 谢谢 Moty Drimmer。我得到了它的工作,虽然我现在在网关 API 和使用参数的云函数调用方面遇到问题,但这对于另一个线程来说是值得的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-15
  • 2021-12-01
  • 1970-01-01
  • 2022-01-03
  • 2010-12-28
  • 1970-01-01
相关资源
最近更新 更多