简体   繁体   English

没有默认 App ID 登录小部件的社交 IBM App ID 登录

[英]Social IBM App ID login without default App ID login widget

I'm required to implement login using google/facebook from clients own front end application using IBM App ID service.我需要使用 google/facebook 从客户自己的前端应用程序使用IBM App ID服务实现登录。 Meaning login widget that is provided by IBM must never show .意思是 IBM 提供的登录小部件绝不能显示.

Front end is developed using react js and back-end is separate node-js server.前端使用 react js 开发,后端是单独的 node-js 服务器。 I figured how to bypass widget for cloud directory login but i have no luck for social login.我想出了如何绕过小部件进行云目录登录,但我没有社交登录的运气。 If i just copy form code for google login provided by default IBM app id login widget (copied code is as follows)如果我只是复制默认 IBM app 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>

Sometimes I get the following (it worked few times but redirect was to backend "/" route for some reason)有时我会得到以下信息(它工作了几次,但由于某种原因重定向到后端“/”路由)

{
"error_code": "GENERAL_ERROR",
"error_description": "key not found"
}

Question is how do i implement social login with custom UI and what do i have to send to passport in order to login, get token and user data.问题是我如何使用自定义 UI 实现社交登录,以及我必须向护照发送什么才能登录、获取令牌和用户数据。 And how to redirect with that data to front-end server.以及如何将该数据重定向到前端服务器。 (Front end is on seperate server and communication with backend is REST so token must be sent with each request) (前端在单独的服务器上,与后端的通信是 REST,因此必须随每个请求发送令牌)

I've been stuck on this problem for a few days without any luck so any help would be greatly appreciated.我已经被这个问题困住了几天没有任何运气所以任何帮助将不胜感激。 I'd appreciate code example showing how to login using google or facebook from custom fronted to nodejs backend using IBM App ID but any help at all would help.我很欣赏代码示例,该示例展示了如何使用 google 或 facebook 从自定义前端登录到使用 IBM App ID 的 nodejs 后端,但任何帮助都会有所帮助。

Thank you in advance先感谢您

If you want to have FB, Google, and Cloud Directory logins without showing the widget, you will need 3 different App ID instances.如果您希望在不显示小部件的情况下登录 FB、Google 和 Cloud Directory,则需要 3 个不同的 App ID 实例。 Each one configured to only have one identity provider.每个配置为只有一个身份提供者。

If you have all the other Identity Providers disabled in App ID, then you should be forwarded directly to google authentication.如果您在 App ID 中禁用了所有其他身份提供者,那么您应该被直接转发到 google 身份验证。 That way the login widget of App ID should not be shown.这样就不应显示 App ID 的登录小部件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM