Where to finddRealM ID for QuickBooks online App - quickbooks

I want to integrate QuickBooks Online app with my PHP application. I have downloaded the latest PHP SDK. But there I need realm id to start with. Please help me here.
And if any other requirements I need, please guide me for the same.

Please take a look at the documentation as you need to go through a 3 legged Oauth process and in your callback URL you will receive the realmId.
https://developer.intuit.com/docs/0025_quickbooksapi/0010_getting_started
regards,
Jarred

I built a nice sample app that you can run:
http://runnable.com/UtEZ4OpSEoFzAACs/quickbooks-oauth-%2B-list-customers-example-for-php-intuit-intuit-partner-platform-and-ipp
Ping me if you have issues running this code.
If you go to the index.php file and uncomment the line:
//echo "realmId: $realmId <br />";
That will print the realmId for you.
After you implement Oauth one of the returns from the Oauth process is the realmID.

If you use our open source PHP DevKit it includes a sample of how to get your realm ID and other OAuth credentials. It's also documented on Intuit's website - but unless you're very familiar with OAuth, usually it's easier to start with something pre-built.
If you take a look at the example app we provide:
https://github.com/consolibyte/quickbooks-php/tree/master/docs/example_app_ipp_v3
It comes with the components to get your OAuth tokens built-in. You just slap a bit of JavaScript on your page:
<script type="text/javascript" src="https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js"></script>
<script type="text/javascript">
intuit.ipp.anywhere.setup({
menuProxy: '<?php print($quickbooks_menu_url); ?>',
grantUrl: '<?php print($quickbooks_oauth_url); ?>'
});
</script>
<ipp:connectToIntuit></ipp:connectToIntuit>
Which show's the "Connect to QuickBooks" button on your site. Click the button and you'll be walked through getting the OAuth tokens and realm ID. They will automatically be stored in a database so you can use them to access data from QuickBooks Online.
Data access is then as easy as:
// Get our OAuth credentials from the database $creds =
$IntuitAnywhere->load($the_username, $the_tenant);
// Tell the framework to load some data from the OAuth store
$IPP->authMode(
QuickBooks_IPP::AUTHMODE_OAUTH,
$the_username,
$creds);
// This is our current realm $realm = $creds['qb_realm'];
// Load the OAuth information from the database if ($Context =
$IPP->context()) {
// Set the IPP version to v3
$IPP->version(QuickBooks_IPP_IDS::VERSION_3);
$CustomerService = new QuickBooks_IPP_Service_Customer();
$customers = $CustomerService->query($Context, $realm, "SELECT * FROM Customer ");
Additional help for using the DevKit can be found on these forums.

Related

Google Sheets Add-on error: authorisation is required to perform that action

I have an add-on that worked for years inside my domain/company until Google decided to change stuff.
I republished it and now I can run it but nobody else in the company can.
The error they receive is:
"Authorisation is required to perform that action".
I cannot pinpoint exactly where the error is because the GCP Log only tells me the function not the line, but it seems most of the times the error appears when showing a sidebar.
I do not use any kind of API, simply GAS but "just in case " I added in OAuth consent screen these scopes: .../auth/script.container.ui and .../auth/spreadsheets.
In Google Workspace Marketplace SDK OAuth Scopes I've just left the default.
Also I tried adding in appscript.json this (at top level):
"oauthScopes": [
"https://www.googleapis.com/auth/script.container.ui",
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/script.scriptapp",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/userinfo.email"
]
What else can I try ?
Update: as requested in comments here's the offending code:
// clientside
google.script.run.
withSuccessHandler()
.withFailureHandler(failureHandler) // failureHandler gets called
.aServerFunc()
//serverside
function aServerFunc(){
Logger.log('REACHED') // NO REACHED APPEARS IN CLOUD LOGS !
var docProp = PropertiesService.getDocumentProperties();
return docProp.getProperty(key)
}
So I guess the problem is nobody else but me can run google.script.run in an add-on !
Update 2:
I've removed the PropertiesService calls so it's just a blank function on the server. So it's clear that nobody but me can run google.scripts.run.
Update 3:
As required in the comments here's the procedures I did to publish the add-on:
I created a google cloud project, then configured the OAuth consentscreen (with the same scopes as appsscript.json - see above list), then in Google Workspace Marketplace SDK I've set the script ID and deployment number and the same scopes and published.
It turns out the add-on was just fine !
It's just this 4 years old bug that Google refuses to fix
If the user is logged in with multiple accounts the default one will be used.
If the default account is non-domain and the add-on is restricted to a domain the add-on will fail to authorise.

How to Register a new OAuth applicationin github

I am trying to make a site from code https://github.com/prose/prose
site link is http://editor.jus.in what should be my Homepage URL and Authorization callback URL for this application on https://github.com/settings/applications/new ?
In apps documentation it says
1.Redirect users to request GitHub access.
GET https://github.com/login/oauth/authorize
2.GitHub redirects back to your site including a temporary code you need for the next step.
You can grab it like so:
var code = window.location.href.match(/\?code=(.*)/)[1];
3.Request the actual token using your instance of Gatekeeper, which knows your client_secret.
$.getJSON('http://localhost:9999/authenticate/'+code, function(data) {
console.log(data.token);
});
Where should I do these changes?
Thanks.
I need to build master branch locally

Missing 'onload.js' file breaks Chrome Extensions OAuth

I am going through the process of updating a Google Chrome extension from Manifest v1 to Manifest v2. I won't say that things have been going swimmingly, largely due to outdated documentation at Google's own Chrome Extensions website.
Here is the latest:
Google's documentation for using OAuth from within an extension tells me to include the following three files in my manifest:
chrome_ex_oauth.html
chrome_ex_oauth.js
chrome_ex_oauthsimple.js
The first of these files, chrome_ex_oauth.html, is basically the redirect page that is opened when an extension first uses OAuth to get an initial request token. In the updated version of this very spare webpage, the head section lists three javascript files to load: the two listed above, and one called:
onload.js
When chrome_ex_oauth.html is opened by my extension, I get no indication of errors beyond a failure to load the non-existent 'onload.js' file. Clearly, I am missing something here. The OAuth sequence never succeeds in completing, and indeed there is no indication that it is ever initiated.
Does anybody know what I'm doing wrong?
After posting this question, I compared the old and new versions of chrome_ex_oauth.html. I saw that in the former, while there was no mention of the onload.js script, there was the following in the head:
<script type="text/javascript">
function onLoad() {
ChromeExOAuth.initCallbackPage();
};
</script>
This function was called inline:
<body onload="onload();">
...
As of Manifest v2, it is my understanding that inline javascript is strictly prohibited, so this couldn't fly. A call to load onload.js was added to the document head instead. It looks as if a link to the actual file in Google's documentation was overlooked. It's easy enough to write, but here is what I put in onload.js:
window.onload = function() { ChromeExOAuth.initCallbackPage(); };
After that, the redirect worked just fine and I was able to complete the OAuth process.
Let me know if it doesn't work for you.

Google oAuth example

I'm looking for a worked example of how to call into Googles oAuth service with a view to simply uploading a txt file. On googles docs I have the followed the example
http://code.google.com/p/google-api-java-client/wiki/OAuth2
but it won't compile .... CalendarScopes.CALENDAR is the problem and I can't see what Jar contains this class. I imported every Jar in the google-oauth-java-client-1.12.0-beta download (Also every jar in google-api-java-client-1.12.0-beta ) I dobn't understand the diff between these but that is for another day.
Any pointers would be welcome.
CalendarScopes.CALENDAR that you mentioned is not a part of a jar file but a scope for Calendar API provided by Google. For a sample to show how to implement that, here is one.
In the meanwhile, I would also suggest going over the following links to develop an understanding of the OAuth and how to use it with the different APIs.
OAuth Playground - This is very helpful when trying to learn about different API and permissions relating to those.
OpenID Connect Official Documentation
Hope this helps.

server not retrieving GET statuses/user_timeline information from twitter

I'm trying to create a simple widget to retrieve a users feeds, I have fully set my application up to work with the #anywhere an OAuth functionality of twitter's API.
The problem I'm having is when I try to retrieve a users tweets and writing them out again to a text file.
My code for doing so is as follows
<?php
$cache = dirname(__FILE__) . '/../cache/twitter-json.txt';
$data = file_get_contents('http://api.twitter.com/1/statuses/user_timeline/screen_name.json?count=3&include_rts=true&include_entities=true');
$cachefile = fopen($cache, 'wb');
fwrite($cachefile,utf8_encode($data));
fclose($cachefile);
?>
okay now this code works great when I run the application locally but form some reason it does not work when I deploy it to the server.
It creates the cache file on the server and any test data I added to check if the file writing procedure worked.
I have not set up the server on my own it is run by an external company I'm just using ftp commands to deploy the web application
Any help and ideas would be appreciated
Check with your host - they have almost certainly disallowed file_get_contents for security reasons.
Your options are
Ask them to enable it by editing php.ini to allow_url_fopen
Use cURL to make the call
Here's a basic example using curl in php
$url = "http://api.twitter.com/1/statuses/user_timeline/screen_name.json?count=3&include_rts=true&include_entities=true"
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl_handle,CURLOPT_URL,$url);
$data = curl_exec($curl_handle);
curl_close($curl_handle);

Resources