Unexplained 403 Forbidden for WebRTC

I'm trying to get the WebRTC SDK up and running using the test pages located in the git repo:

Specifically, index-template.html.

I have a local http server up and running and I can navigate to http://127.0.0.1:8080/index-template.html

I have everything up and running, and I can authenticate with the redirect url set up and I get in the address bar:
http://127.0.0.1:8080/index-template.html#access_token=NEW_TOKEN&token_type=bearer

So that's working. But when I click Start App I get:
Fri Jun 28 2019 17:14:52 GMT-0700 (Mountain Standard Time)
error

error: Failed to initialize SDK

details: Error: Forbidden

Fri Jun 28 2019 17:14:52 GMT-0700 (Mountain Standard Time)
Error: Failed to initialize SDK

I open up Chrome Dev Tool to see where the error is coming from, and I see:

  1. Request URL:
    https://api.mypurecloud.com/api/v2/organizations/me

  2. Request Method:
    GET

  3. Status Code:
    403 Forbidden

  4. Remote Address:
    XX.XXX.XXX.XXX:443

  5. Referrer Policy:
    no-referrer-when-downgrade

With the response being:
{"status":403,"code":"forbidden","message":"App not authorized to use scope [organization, organization:readonly]","details":[],"errors":[]}

I copied the command in Curl to see what I get there, and the response was the same.

GET /api/v2/organizations/me is documented as requiring one of these scopes:

  • organization
  • organization:readonly

So I went to check my OAuth Scope settings and I see I already have organization there (I also tried organization:readonly but that didn't work either):

I also checked my Authorized redirect URIs and I have everything there. The forums don't allow me to type them out, but I have localhost 8080, 127 8080, 127 8080 appended by index-template.html, and all of them with and without a trailing slash just in case.

I don't know what I'm missing. I tried adding every single scope, and that didn't work either.

@crcya Can you get the ININ-Correlation-Id Response header value that comes back with the 403? That'll help narrow down the specific error.

It looks like this may just be a bug with the sample app. I'm able to reproduce this.

Try clicking "authenticate" a second time after being redirected back with an auth token. The second time, you should not see the access token in the URL. (Also be sure to select pca-us as the environment both times). I'll get a ticket created to fix this in the sample application.

Hmm I'm now seeing a 403 on permissions and the 403 for the organizations/me call.

The ININ-Correlation-IDs for them respectively:
5c570699-2105-468f-804d-a5850bea72eb
ea50ec05-1bbf-4e01-845a-31b6840ed974

I tried clicking Authenticate twice, the access_token is still in the url from the redirect

Ok, thanks for confirming. It's different from what I was seeing. Logs confirm it's a scopes issue. I'll try to loop in someone who has more information on that.

You're terrific for taking care of this, thanks!

If I have anything to share on this topic, I'll post it here.

@crcya It looks like you OAuth client is configured correctly so check to see if your OAuth client has been authorized by visiting https://apps.mypurecloud.com/directory/#/admin/oauth/authorizations and looking for that client in the list. If it is not there, you can authorize it to use those scopes by clicking the "Authorize a Client" button and copy/pasting your client ID in the text box. That will take you to a page where you can authorize the client.

For using the SDK with scopes, You'll need the scopes authorization, conversations, organization, and notifications - I'll work on getting this documented.

If I try clicking that link, PureCloud loads forever but doesn't navigate me anywhere:

I tried finding it manually, but the closest I could find was:
https://apps.mypurecloud.com/directory/#/admin/integrations/apps

Is that the link? If so, I have an integration with the Application URL of http://127.0.0.1:8080, the Application Type as "standalone", and the iframe sandbox options as "allow-scripts,allow-same-origin,allow-forms,allow-modals"

Super, in the meantime I tried adding those scopes and I'm getting the this error. The Network log:

Permissions is still failing, but the /me fails, but then retries(?) and gets a 200. But I still get the following log on the page:
Mon Jul 01 2019 11:22:23 GMT-0700 (Mountain Standard Time)
error

error: Failed to initialize SDK

details: Error: Forbidden

Mon Jul 01 2019 11:22:23 GMT-0700 (Mountain Standard Time)
Error: Failed to initialize SDK

Mon Jul 01 2019 11:25:27 GMT-0700 (Mountain Standard Time)
error

error: Failed to initialize SDK

details: Error: Forbidden

Mon Jul 01 2019 11:25:27 GMT-0700 (Mountain Standard Time)
Error: Failed to initialize SDK

I double-checked and that is the correct link. Perhaps you don't have permission to view that page. Please make sure you have the "oauth:clients:authorize" permission.

Where do I set that?

Playing around with https://sdk-cdn.mypurecloud.com/webrtc-sdk/demo/webpack/ that's starting just fine to no surprise. Looking at the page source it's using 6b9f791c-86ef-4f7a-af85-3f3520dd0975. How is that client configured? Maybe if I can compare that to mine the difference can be found.

Thanks!

It may be easier to ask your admin to authorize the client for you. I think it's likely that if you don't have access to the Authorized Applications view, you probably won't be able to add permissions to your user.

You can get a URL to the client authorization by visiting your OAuth client config and scrolling down to the area that displays your client ID and secret. There is a text box containing a URL.

Copy that URL and send it to your admin who should be able to view that page and authorize your client.

That worked! I am the admin and still can't access /oauth/authorizations, but going to that authorization URL specifically works and I enabled them. The demo page is now working! Can we get that documented somewhere? That seems really important.

A behavior I wasn't expecting was I still have to keep my PureCloud login tab open. I can enter a number into the "Outbound phone call" field of the demo page and dial out, but the call connects in the PureCloud tab. And I'm able to end the call from the demo page too. Is there a way to get around keeping the PureCloud tab open?

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.