Getting access_token and refresh_token from web embbedable token login

  • 1
  • Idea
  • Updated 3 months ago
I am using RingCentral embeddable voice for CRM integration, I could be able the access_token, refresh_token and etc from the browser local storage manually.
Is there any proper way to get the tokens? something like through `rc-login-status-notify` event listeners inside the javascript.
Photo of sharmilan A

sharmilan A

  • 354 Points 250 badge 2x thumb

Posted 3 months ago

  • 1
Photo of Embbnux Ji

Embbnux Ji, Employee

  • 938 Points 500 badge 2x thumb
Hi, Sharmilan

For security problem, now it isn't allowed to pass token by message event directly. Can you tell me why you need the token. Actually you can get most data from widget event. If you need more data, you can create a issue in here, so we can add it into our backlog. https://github.com/ringcentral/ringcentral-embeddable/issues

If you still need access token, you can customize redirect uri and get token from `window.location.href` in implicit auth flow. https://github.com/ringcentral/ringcentral-embeddable/blob/master/docs/config-client-id-and-secret.m...  https://github.com/ringcentral/ringcentral-embeddable/blob/master/docs/customize-redirect-uri.md

Thanks,
Embbnux
Photo of sharmilan A

sharmilan A

  • 354 Points 250 badge 2x thumb
Thanks for your response.
I need to use some APIs and webhooks from the server side too, for track some actions. But, not interested to prompt login screen again for back-end purpose, since I have been already logged in through the widget.
The key purpose is I have to use front-end and the back-end with the single login, So if I update the access_token by using the refresh_token, I have to update front-end as well for the widget access. Or is there any way to use the existing access_token inside the widget?
I hope this is not a new scenario, have you any idea?
Photo of Embbnux Ji

Embbnux Ji, Employee

  • 938 Points 500 badge 2x thumb
Hi, Sharmilan

I am thinking if SSO feature in widget can meet your requirements. Login button in your website page to make user connect ringcentral. After user login,  render the widget and it login with auto redirecting. I am doing some experiment. I will give you feedback after I finish.
Photo of Embbnux Ji

Embbnux Ji, Employee

  • 938 Points 500 badge 2x thumb
Hi, Sharmilan

We just release a beta SSO feature into RingCentral Embeddable. This is the document https://github.com/ringcentral/ringcentral-embeddable/blob/master/docs/sso-login-mode.md Any feedback is very welcome.

Thanks
Photo of sharmilan A

sharmilan A

  • 354 Points 250 badge 2x thumb
Thank you very much,
I going to use this, but I have an unclear point. If I have logged in two instances with different creds, but appKey, appSecret are the same in both instances since same sandbox. Then If I use widget, how it's going to use the correct RingCentral or which account will be use.
Thanks
(Edited)
Photo of Embbnux Ji

Embbnux Ji, Employee

  • 938 Points 500 badge 2x thumb
Hi, Sharmilan, for sso, two instance should be same account. If we want to check user info, you can require `/account/~/extension/~` api