用于serverles SPA的App ID Custom Widget

问题描述 投票:0回答:1

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

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

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

我找不到文档https://console.bluemix.net/catalog/services/app-id的线索

想法?

@Jarkko

ibm-cloud ibm-appid
1个回答
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: "[email protected]",
                password: "11111111"
            }
        }, function (error, response, body) {
            resolve(response);
            // handle errors...
        });
    })
}

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

© www.soinside.com 2019 - 2024. All rights reserved.