IntuitDeveloper / HelloWorld-PHP

Starter app in PHP using OAuth2 that demonstrates how to make a QBO API Call
Apache License 2.0
33 stars 46 forks source link
oauth2 php quickbooks-api

Rate your SampleYesNo

Intuit OAuth2.0 and OpenID Connect Demo in PHP

Overview

This is a sample Demo app in PHP to showcase how to Authorize using OAuth2.0 and OpenID Connect and to make API calls using the QuickBooks-V3-PHP-SDK SDK

This sample app is meant to showcase an example of how to integrate your app with the Intuit Developer Platform. It showcases the following:

Installation

Via Github Repo (Recommended)

$ git clone https://github.com/IntuitDeveloper/HelloWorld-PHP.git
$ cd HelloWorld-PHP
$ curl -sS https://getcomposer.org/installer | php
$ composer install

Pre-requisites

Configuration

Edit the config.php file to add your:

In the Developer Portal, ensure the redirect URI in your config.json file has been entered in your app configuration. By default, the URL is set to the following for this demo:

http://localhost:3000/callback.php

TLS / SSL (optional)

If you want your enpoint to be exposed over the internet. The easiest way to do that while you are still developing your code locally is to use ngrok.

Here are the steps to configure ngrok

  1. Download and install ngrok
  2. Expose your localhost by running "ngrok http 3000" on the command line.
  3. You will then get a forwarding url that looks something like this: Forwarding https://755c8b38.ngrok.io -> localhost:3000

This will expose localhost:3000 to the Internet. Your endpoint url will now be https://755c8b38.ngrok.io/callback.php Copy this url and use it for setting the redirectUri Intuit Developer Portal for your app.

Difference between OAuth2.0 and OpenID Connect

Lets take a look at the key differences between OAuth2.0 and OpenID connect as per the authorization flow is : Auth Flow

Usage

$ php -S localhost:3000

Start ngrok (if you are using ngrok )

$ ngrok http 3000

Go to the URL (you must start ngrok if using it):

https://755c8b38.ngrok.io/

Then click the button to authorize the demo app and view the access token.

Events are logged to the Node.js console.

APP screenshots