intuit / oauth-jsclient

Intuit's NodeJS OAuth client provides a set of methods to make it easier to work with OAuth2.0 and Open ID
https://developer.intuit.com/
Apache License 2.0
120 stars 154 forks source link

Permission denied error trying to access Reports #89

Closed dan-yave closed 4 years ago

dan-yave commented 4 years ago

Hi Are there special permissions needed to access the reports? i see them listed in the API yet i get permissions error when trying to execute. I thought it was my code but i get the same error in the sample app. For a minimum test i simply updated the endpoint on the app.js getCompanyInfo endpoint just to see if it would work. (in sandbox using ngrok)

App.js lines 125 - 130

app.get('/getCompanyInfo', function(req,res){ const companyID = oauthClient.getToken().realmId;

const url = oauthClient.environment == 'sandbox' ? OAuthClient.environment.sandbox : OAuthClient.environment.production ;

// oauthClient.makeApiCall({url: url + 'v3/company/' + companyID +'/companyinfo/' + companyID})
oauthClient.makeApiCall({url: url + 'v3/company/' + companyID +'/reports/Cashflow'})

....

here is the response

Response { Url: [Url], rawHeaders: [Array], body: '{"Fault":{"Error":[{"Message":"Permission Denied Error","Detail":"Permission Denied Error : You do not have the access rights to use this feature.","code":"5020","element":"ReportName"}],"type":"ValidationFault"},"time":"2020-05-13T10:46:45.761-07:00"}', status: 400, statusText: 'Bad Request' }

I tried all the various scopes and still no luck.

I am able to access the reports via my sandbox company id online but just not through the API call.

thanks Dan

abisalehalliprasan commented 4 years ago

@dan-yave : You would get this error only if the QBO subscription does not support it. You can see it here : https://help.developer.intuit.com/s/article/5020-Permission-Denied-Error However, since you are saying this is happening on sandbox QBO, We might need to see our logs to see if there is an issue with your sandbox company.

Please log a support ticket here and also provide response headers. We will provide more information on the ticket.

dan-yave commented 4 years ago

Thanks @abisalehalliprasan i dont think there is an issue with my sandbox company, i havent modified it since it was created for me when i set up my developer account and i can log in and run all the reports w/o issue.

Also i found an older version of the intuit OAuth Client https://github.com/IntuitDeveloper/oauth2-nodejs and just to test i was able to execute reports using that sample code - trying to compare code bases to see what is different between the two.

so for example this code works using my same companyId and my sandbox api keys https://github.com/IntuitDeveloper/oauth2-nodejs/blob/master/routes/api_call.js

Thanks Dan

abisalehalliprasan commented 4 years ago

Are you sure that the above error is for the sandbox company? Going by the error code: 5020, it means the company does not have permission to access this feature. I will need intuit_tid from response headers to verify this information.

dan-yave commented 4 years ago

ok - i could be wrong let me double check

dan-yave commented 4 years ago

I'm definitely going to sandbox api and i verified my company Id for Sandbox Company_US_1 - i can DM it to you if you want.

here is the tid: 1-5ebc47a8-fd471c01b385812d4eaa7539

thanks for looking into this

dan-yave commented 4 years ago

i can send the full response from the logs if you need

dan-yave commented 4 years ago

use this tid instead - 1-5ebc4a0c-1c1c793d64af4bdaa6ff5d29

abisalehalliprasan commented 4 years ago

@dan-yave : sorry for the late reply. The team did look at the logs and it looked like it is a one-off case where the particular sandbox was already expired. We could renew it but a better option would be to create a new sandbox.

Closing the issue.

dan-yave commented 4 years ago

@abisalehalliprasan they must be mistaken my sandbox is NOT expired. I opened it a month ago and log in nearly every day while i work on this project.

Did you try accessing a report using your sample project - from any sandbox?

abisalehalliprasan commented 4 years ago

@dan-yave : By expired. I mean using the API, you will not be able to access this feature.

You will still be able to use the sandbox in UI. However, due to some mismatch this particular sandbox with company ID 4620816365046826340 is having the problem.

yes.The sample project works for all sandbox companies.

dan-yave commented 4 years ago

@abisalehalliprasan not sure what that means but OK

I created a new sandbox company : 4620816365062879630 I get the same exact error : Here is the tid: 1-5ec877cd-e181bbfa8606471cc5e63212

I'm running your sample, other than the report endpoint i did not alter your code

image

abisalehalliprasan commented 4 years ago

Can you provide your email? we can do a screen share.

abisalehalliprasan commented 4 years ago

@dan-yave : Figured out the issue. Its the Letter f notice your URL above : {url: url + 'v3/company/' + companyID +'/reports/Cashflow'}

change the URL to {url: url + 'v3/company/' + companyID +'/reports/CashFlow'}

From our API reference it should be of the format :

GET /v3/company/<companyiD>/reports/CashFlow?<name>=<value>[&...]&minorversion=47

Accept type:application/json
Production Base URL:https://quickbooks.api.intuit.com
Sandbox Base URL:https://sandbox-quickbooks.api.intuit.com
dan-yave commented 4 years ago

@abisalehalliprasan - ugggg - so sorry to waste your time. I swear i thought that was the first thing i checked before submitting the ticket. i realize now i had it correct in one project but wrong in the other - apologies.

thanks again for all your help!