gpt4 book ai didi

javascript - RingCentral JavaScript SDK 处理重定向 URI 指向本地 JavaScript 函数

转载 作者:行者123 更新时间:2023-12-03 02:51:51 25 4
gpt4 key购买 nike

RingCentral JavaScript SDK处理指向本地 JavaScript 函数的重定向 URI

根据文档,他们提供了选项

RingCentral.SDK.handleLoginRedirect()

但不知道如何使用

var SDK = require('ringcentral');
rcsdk = new SDK({
server: SDK.server.sandbox,
appKey: '_app_key',
appSecret: 'app_password',
redirectUri: ''
})
function handleredirectURI(){
//handle redirections
}

我们需要指出我们的handleredirectURI函数提前致谢

最佳答案

根据文档。上下文是 3 足 oAuth。这是一个演示:https://github.com/ringcentral/ringcentral-demos-oauth/tree/master/javascript

但是该演示不使用 handleredirectURI 方法。这意味着该方法只是一个实用方法,不需要使用它。

关于handleredirectURI的使用,我稍后会回来更新我的答案。

更新

这里是handleredirectURI的源代码:https://github.com/ringcentral/ringcentral-js/blob/669b7d06254d3620c5a5f24c94b401aa862be948/src/SDK.js#L115-L124

您可以看到该方法解析 win.location 以获取一些有用的数据,并将 postMessage 返回到其开启器。

handleredirectURI 的单元测试:https://github.com/ringcentral/ringcentral-js/blob/669b7d06254d3620c5a5f24c94b401aa862be948/src/SDK-spec.js#L27-L63

更新2

我再次阅读了handleredirectURI'源代码、单元测试、示例代码,我认为它的用法就像它的文档中写的一样:

Popup Setup

This setup is good when your app is rendered as a widget on a third-party sites.

If you would like to simply open RingCentral login pages in a popup, you may use the following short-hand in your app's login page:

var platform = rcsdk.platform();
var loginUrl = platform.loginUrl({implicit: true}); // implicit parameter is optional, default false
platform
.loginWindow({url: loginUrl}) // this method also allows to supply more options to control window position
.then(function (loginOptions){
return platform.login(loginOptions);
})
.then(...)
.catch(...);

In this case your landing page (the one to which Redirect URI points) need to call the following code:

RingCentral.SDK.handleLoginRedirect();

解释:

  • 运行第一个代码片段以打开登录弹出窗口。
  • 在重定向到的页面中,运行第二个代码片段(这行代码)以完成其他所有操作。
  • 授权部分完成后,您就可以调用其他API了。

如果您还有其他问题,请告诉我。

关于javascript - RingCentral JavaScript SDK 处理重定向 URI 指向本地 JavaScript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47815441/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com