Here we will show how to quickly integrate Sequencing OAuth2 harnesses into your Perl 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 Linux environment with Apache2 with
- you need a Perl with following packages installed via CPAN
Let's assume you have a website located in /var/www/html folder.
Configure Apache cgi handler for Perl scripts
Options Indexes FollowSymLinks ExecCGI
Allow from all
AddHandler cgi-script .pl
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 Perl resources to your hosted folder
cp OAuth2-code-with-demo/perl/* /var/www/html/oauth/
4) Now, edit configuration settings in /var/www/html/oauth/index.pl 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.pl should be changed as follows
|Source index.pl snippet||Changed index.pl snippet|
# Example of Sequencing API usage for external developers.
# ID of your oauth2 app (oauth2 client).
# You will be able to get this value from Sequencing website.
my $client_id = 'oAuth2 Demo Perl';
# Secret of your oauth2 app (oauth2 client).
# You will be able to get this value from Sequencing website. Keep this value
my $client_secret = 'z7EaaKQGzLGSqXGQ7yOJlcCqynIyYaKCaxahwWuC2YBAhoduP18jWLM5VtkWOWq9-kOhVoWtWmwE5aBjlpcsaA';
# Redirect URI of your oauth2 app, where it expects Sequencing oAuth2 to
# redirect browser.
my $redirect_uri = 'https://perl-oauth-demo.sequencing.com/Default/Authcallback';
5) Point your browse to http://feedme.com/oauth/index.pl
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 obtained on line 185 of index.pl. We recommend storing them in user session and keeping safe.