Here we will show how to quickly integrate Sequencing OAuth2 harnesses into your .NET/C# 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 Windows environment with Visual Studio
You can just clone it and by modifying OAuth2 related settings specified below get working project quickly.
We have also deployed this code so you can test it in action here.
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
3) Check dot-net-cs directory which contains sample
4) Copy resources to your project
5) 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,
Web.config should be changed as follows
Web.config snippet from repository | Web.config snippet with appropriate OAuth2 tokens |
---|---|
<appSettings> <add key="webpages:Version" value="3.0.0.0"/> <add key="webpages:Enabled" value="false"/> <add key="ClientValidationEnabled" value="true"/> <add key="UnobtrusiveJavaScriptEnabled" value="true"/> <add key="OAuthRedirectUrl" value="http://localhost:64140/Default/AuthCallback"/> <add key="OAuthAppId" value="Sample Code"/> <add key="OAuthSecret" value="WDhTcoqpgnG7R_1A5tsGzNMheS-jyWd-DnRlr4N150YD2eZlaSFsGVszpfeOxGMpjeWH5gWNIkiW5bxuIoDjfg"/> <add key="ApiUrl" value="https://api.sequencing.com/"/> <add key="OAuthUrl" value="https://sequencing.com/indexApi.php"/> </appSettings> |
<appSettings> <add key="webpages:Version" value="3.0.0.0"/> <add key="webpages:Enabled" value="false"/> <add key="ClientValidationEnabled" value="true"/> <add key="UnobtrusiveJavaScriptEnabled" value="true"/> <add key="OAuthRedirectUrl" value="http://feedme.com/Default/AuthCallback"/> <add key="OAuthAppId" value="Sample Code"/> <add key="OAuthSecret" value="RCGK_tcZliZw2z5BqCSr_r-psBTTGBqji_WWEyjNZnp8-eQ1hgle5d1IS_of_U7wkshNvCqXBs25B6Q7JL1EBA"/> <add key="ApiUrl" value="https://api.sequencing.com/"/> <add key="OAuthUrl" value="https://sequencing.com/indexApi.php"/> </appSettings> |
5) Point your browse to http://feedme.com/sequencing/AuthCallback
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. That one is AuthInfo that is obtained on lines 59 of Controllers.AuthWorker class. We recommend storing them in user session and keeping safe.