Here we will show how to quickly integrate Sequencing OAuth2 harnesses into your PHP based environment.
There are several prerequisites in order to complete the integration:
- you need to have a Sequencing account
- you need to have an OAuth2 application secret
- you need to have at least a LAMP environment with Apache2, PHP5 with curl module
Let's assume you have a website located in /var/www/html folder.
In order to complete integration follow instructions below
1) Visit https://github.com/SequencingDOTcom/OAuth2-code-with-demo repository
2) Clone repository locally to your environment
$ git clone https://github.com/SequencingDOTcom/OAuth2-code-with-demo.git
3) Copy PHP resources to your hosted folder
$ mkdir /var/www/html/oauth
$ cp OAuth2-code-with-demo/php/* /var/www/html/oauth/
4) Now, edit configuration settings in /var/www/html/oauth/index.php so to make them conform your OAuth2 application settings. Make sure that application name, secret and redirect URL matches.
OAuth2 management interface is available in the developer center under "Manage OAuth2 secrets" section.
For our test feedme application mentioned the section and looking as shown below,
index.php should be changed as follows
|Source index.php snippet||Changed index.php snippet|
* ID of your oauth2 app (oauth2 client).
* You will be able to get this value from Sequencing website.
$client_id = 'oAuth2 Demo PHP';
* Secret of your oauth2 app (oauth2 client).
* You will be able to get this value from Sequencing website. Keep this value
$client_secret = 'at867K7W88Pxrut1kEFZiOXh2Ij36q6dgEDBZyXte-rhYzBqrI_ay609awMD6ZEtGbuPHQnnW9zzncnOpxbdyg';
* Redirect URI of your oauth2 app, where it expects Sequencing oAuth2 to
* redirect browser.
$redirect_uri = 'https://php-oauth-demo.sequencing.com/index.php';
5) Point your browse to http://feedme.com/oauth/index.php
It will trigger redirect to Sequencing authorization page
After entering credentials you will be presented with access approval which contains application details
After clicking on "Yes (I authorize access)" result page will render (result.php) that contains list of sample files available in your account.
From the code perspective you need to note several important variables that are needed to communicate with Sequencing backend. Those are $access_token and $refresh_token that are obtained on lines 102-103 of index.php. We recommend storing them in user session and keeping safe.