Skip to content
This repository has been archived by the owner. It is now read-only.

Access Denied #2

Closed
ConnorBl opened this issue May 26, 2016 · 3 comments

Comments

@ConnorBl
Copy link

commented May 26, 2016

When I currently run npm start I receive the following:
LOGIN FAILURE DATA: { [Error: Access Denied.]

With that, I have two questions. First, the url specified in the response data is url: 'https://platform.devtest.ringcentral.com/restapi/oauth/token', but I assume this should be platform.ringcentral as I am using production credentials for production call logs?

When RC_API_BASE_URL=https://platform.ringcentral.com I still receive the same error message.

Second, in .env I set RC_APP_SECRET to an access token I retrieve with our production credentials prior to running npm start. Does this sound correct?

This is the current response

Server is listening on port: 3000

LOGIN FAILURE DATA:  { [Error: Access Denied.]
  apiResponse: 
   { _request: 
      { method: 'POST',
        redirect: 'follow',
        headers: [Object],
        url: 'https://platform.ringcentral.com/restapi/oauth/token',
        follow: 20,
        compress: true,
        counter: 0,
        agent: undefined,
        body: 'grant_type=password&username=...&password=...&extension=...',
        bodyUsed: false,
        size: 0,
        timeout: 0,
        _raw: [],
        _abort: false,
        protocol: 'https:',
        hostname: 'platform.ringcentral.com',
        port: null,
        path: '/restapi/oauth/token',
        auth: null,
        originalBody: 'grant_type=password&username=...&password=...&extension=...' },
     _response: 
      { url: 'https://platform.ringcentral.com/restapi/oauth/token',
        status: 400,
        statusText: 'Bad Request',
        headers: [Object],
        ok: false,
        body: [Object],
        bodyUsed: true,
        size: 0,
        timeout: 0,
        _raw: [Object],
        _abort: false,
        _bytes: 77 },
     _text: '{\r\n  "error" : "invalid_client",\r\n  "error_description" : "Access Denied."\r\n}',
     _json: { error: 'invalid_client', error_description: 'Access Denied.' },
     _multipart: [] },
  originalMessage: 'Response has unsuccessful status' }
ERROR:  { [Error: Access Denied.]
  apiResponse: 
   { _request: 
      { method: 'POST',
        redirect: 'follow',
        headers: [Object],
        url: 'https://platform.ringcentral.com/restapi/oauth/token',
        follow: 20,
        compress: true,
        counter: 0,
        agent: undefined,
        body: 'grant_type=password&username=...&password=...&extension=...',
        bodyUsed: false,
        size: 0,
        timeout: 0,
        _raw: [],
        _abort: false,
        protocol: 'https:',
        hostname: 'platform.ringcentral.com',
        port: null,
        path: '/restapi/oauth/token',
        auth: null,
        originalBody: 'grant_type=password&username=...&password=...&extension=...' },
     _response: 
      { url: 'https://platform.ringcentral.com/restapi/oauth/token',
        status: 400,
        statusText: 'Bad Request',
        headers: [Object],
        ok: false,
        body: [Object],
        bodyUsed: true,
        size: 0,
        timeout: 0,
        _raw: [Object],
        _abort: false,
        _bytes: 77 },
     _text: '{\r\n  "error" : "invalid_client",\r\n  "error_description" : "Access Denied."\r\n}',
     _json: { error: 'invalid_client', error_description: 'Access Denied.' },
     _multipart: [] },
  originalMessage: 'Response has unsuccessful status' }
@bdeanindy

This comment has been minimized.

Copy link
Owner

commented May 26, 2016

@ConnorBl

The url specified in the response data is url: https://platform.devtest.ringcentral.com/restapi/oauth/token, but I assume this should be as I am using production credentials for production call logs?

ANSWER: Two items here:

  1. The environment you use is dependent upon the state of your application as defined in the RingCentral Developer Portal. If you have an application defined, but it has not applied for (and been approved for) production access, then you would want to use the Sandbox Base URI: https://platform.devtest.ringcentral.com.
  2. The proper RingCentral API Base URI for production is: https://platform.ringcentral.com but as stated in the previous item, this requires your application defined in the RingCentral Developer Portal to have applied and been approved for Production API access. Otherwise you will receive the error message you are receiving.

When RC_API_BASE_URL=https://platform.ringcentral.com I still receive the same error message.

ANSWER: Please see my response to the former item

In .env I set RC_APP_SECRET to an access token I retrieve with our production credentials prior to running npm start. Does this sound correct?

ANSWER: No, this is not correct (if you're using this application code directly for testing the ability to download call logs from your account in the Sandbox). The correct workflow is to add the RC_APP_KEY and RC_APP_SECRET (aka: your RingCentral Application's API Keys) in the .env file (which simulates setting environment variables in your deployed application code). The code within this demo application uses the RingCentral JavaScript SDK and RingCentral JavaScript Helper Library and will manage fetching the access_token from RingCentral API OAuth resource for you. Of course, all of this requires that you have created an application in the RingCentral Developer Portal.

Using this demo code in Production

Since this code does not have any tests in place, it is not recommended to use in a production environment, but if you want to test using this in your RingCentral Sandbox account and then apply for production (to see how the process works) you are welcomed. If you choose to do this, once you have applied for production access in the RingCentral Developer Portal for this application, and it has been approved, you would just need to:

  • Update the .env file with your application's new Production API Keys
  • Update the .env file RC_API_BASE_URL property to point to https://platform.ringcentral.com
  • Update the .env file RC_USERNAME, RC_PASSWORD, RC_EXTENSION credentials, which would need to be a user extension which exists and is configured to allow presence event monitoring
@bdeanindy

This comment has been minimized.

Copy link
Owner

commented May 31, 2016

@ConnorBl did the above information answer your question?

@ConnorBl

This comment has been minimized.

Copy link
Author

commented May 31, 2016

Hey Benjamin,

Sorry for the lack of a response, I was away for a long weekend.

Yes, the above did answer my question. I mistook the RC_APP_SECRET for a token that I had to create, where all I needed to do was obtain it from my account information. Once I correctly entered the RC_APP_SECRET this call log download worked great to obtain our production logs.

Just to note, I did run into the issue I believe you warned me about previously,

"errorCode" : "CMN-201",\r\n "message" : "Service Temporary Unavailable",
"errorCode" : "CMN-301",\r\n "message" : "Request rate exceeded",

This would sometimes be the response when the dates I input were too far apart(over two weeks) or I tried to run this script too often.

To get around this I simply put in shorter date ranges and combined the multiple csvs created.

Thank you for all your help, you went above and beyond. 😄

@ConnorBl ConnorBl closed this May 31, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants
You can’t perform that action at this time.