IBM Cloud Function for App ID sign_up 和 forgot_password

IBM Cloud Function for App ID sign_up and forgot_password

我可以使用以下云函数从云中生成令牌

const 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",
                username: params.uid,
                password: params.pwd
            }
        }, function (error, response, body) {
            resolve(response);
        })
    })
}

如何在没有 Node.js SDK 和 Express 服务器的情况下使用 App ID sign_up 和 forgot_password 功能。换句话说,我想让我的应用程序 (SPA) 保持无服务器状态并使用云功能。我已经尝试过,并阅读了文档以找到解决方案,但到目前为止运气不好 (http 404)。

编辑:我试图调用忘记密码页面但结果错误的函数(statusCode 400)"missing redirect"

const main = (params) => {
    return new Promise(function (resolve, reject) {
        request({
            url: credentials.oauthServerUrl + '/forgot_password',
            method: 'GET',
            form: {
                client_id: credentials.clientId,
                redirect_uri: "http://www.google.fi"
            }
        }, function (error, response, body) {
            resolve(response);
        })
    })
}

工作解决方案似乎如下:

const request = require('request');
const credentials = {
  "version": 3,
  "clientId": "xxx",
  "secret": "xxx",
  "tenantId": "xxx",
  "oauthServerUrl": "https://appid-oauth.eu-gb.bluemix.net/oauth/v3/xxx/cloud_directory/forgot_password"
}
const main = (params) => {
    return new Promise(function (resolve, reject) {
        request({
            url: credentials.oauthServerUrl 
                + '?client_id=' + credentials.clientId 
                    + '&redirect_uri=http://www.my.domain'
                ,
            method: 'GET'
        }, function (error, response, body) {
            resolve(response);
        })
    })
}