question

Jeroen Couwenberg avatar image
Jeroen Couwenberg asked Phong Vu commented

Ringcentral returns OAU-153 response

Hello,


We have implemented an implicit grant flow in our login authorization flow. However we have come across a problem when trying to logout. (We assume this is also the problem at other platform(). functions). For that function we use the following code:

function logout() {
    rcsdk.platform().logout()
        .then(function (res) {
            _isLoggedIn = false;
            console.log('rcClient logged out');
            rcWebPhone.userAgent.unregister();
            var onLogout = handlers["onLogout"];
            onLogout();
            loginstatus();
            subscriptionCache.resetSubscription();
        })
        .catch(function (res) {
            console.log('An error occurred while logging out rcClient');
        });
}

The catch catches an error with the following message: "Failed to execute 'fetch' on 'Window': Cannot construct a Request with a Request object that has already been used."

The API response is :

{
  "error" : "invalid_client",
  "errors" : [ {
    "errorCode" : "OAU-153",
    "message" : "Invalid client: ${client_id}"
  } ],
  "error_description" : "Invalid client: ${client_id}"
}


WE cannot pinpoint why it would say it is an invalid client_id because we can use other apicalls before the logout just fine.

I will add also the way we login to be complete in my information:

function show3LeggedLogin() {
    redirectUri = decodeURIComponent(window.location.href.split('rcclient.html', 1) + 'callback.html');
    console.log('Redirect uri: ', redirectUri);
    rcsdk = new SDK({
        appKey: appKey,
        server: server,
        redirectUri: redirectUri
    });
    platform = rcsdk.platform();
    var loginUrl = platform.loginUrl({ implicit: true });
    platform
        .loginWindow({ url: loginUrl }) // this method also allows to supply more options to control window position
        .then(function (loginOptions) {
            return platform.login(loginOptions);
        })
        .then(function (res) {
            // Login success
            return postLogin();
        })
        .catch(function (e) {
            // Login failed
            console.error(e.stack || e);
            var handleLoginFailed = handlers["loginFailed"];
            handleLoginFailed();
        });
}


I hope you can help us or at least steer us in the right direction to solve this. If you need more information please say so!


With kind regards,

Martijn (logged in under Jeroens name)

sdk
1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image Phong Vu ♦♦ commented ·

Just a quick check. Can you double check the rcsdk.platform() instance inside the logout function to see if it is instantiated? I guessed the rcsdk is a global variable but not sure how you implemented it.

0 Likes 0 ·

0 Answers

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys