我需要使用IBM App ID服务从客户自己的前端应用程序使用 google/facebook 实现登录。这意味着 IBM 提供的登录小部件绝不能显示。
前端是使用 react js 开发的,后端是单独的 node-js 服务器。我想出了如何绕过小部件进行云目录登录,但我没有运气进行社交登录。如果我只是复制默认 IBM 应用程序 ID 登录小部件提供的谷歌登录表单代码(复制代码如下)
<form
action="https://accounts.google.com/o/oauth2/v2/auth"
method="get"
id="google_form"
aria-label="google_form"
>
<input
type="hidden"
name="client_id"
value="526589484289-sth1s4he8en575sugh6rain3hh054p97.apps.googleusercontent.com"
id="google_client_id"
></input>
<input
type="hidden"
name="redirect_uri"
value="https://eu-uk.appid.cloud.ibm.com/oauth/v4/DEFAULT-GOOGLE-TENANT-ID/Google/callback"
id="google_redirect_uri"
></input>
<input type="hidden" name="response_type" value="code"></input>
<input
type="hidden"
name="scope"
id="google_scope"
value="email profile"
></input>
<input
type="hidden"
name="state"
value="woU6LcOCwrTDr8OXw63DnQNAwr5xdinCtxcKJsKKYcKWX8OGw5zCoh0Fw4k"
id="google_state"
></input>
<button
type="submit"
id="google_login"
>
<div>Login with Google</div>
</button>
</form>
有时我得到以下信息(它工作了几次,但由于某种原因重定向到后端“/”路由)
{
"error_code": "GENERAL_ERROR",
"error_description": "key not found"
}
问题是我如何使用自定义 UI 实现社交登录,以及我必须向护照发送什么才能登录、获取令牌和用户数据。以及如何将该数据重定向到前端服务器。(前端在单独的服务器上,与后端的通信是 REST,因此必须随每个请求发送令牌)
我已经被这个问题困住了几天,没有任何运气,所以任何帮助将不胜感激。我希望代码示例显示如何使用 google 或 facebook 从自定义前端登录到使用 IBM App ID 的 nodejs 后端,但任何帮助都会有所帮助。
先感谢您