OAuth

The following walkthrough will show you how to integrate Channel i OAuth in your applications.  

 1. Initial Setup  

     Obtain Channel i OAuth credentials from IMG. At this step you’ll need to tell IMG a bit of information about your application : 

  1. Contact IMG to register your application.  

  1. Set your application URL and redirect URL(s). (The URL(s) to which the response of your request will be sent.) 

  1. Mention the information you need.  

  1. Make a note of both your client_id and client_secret. 


2. The First Leg 

     First, direct your user to https://channeli.in/oauth/ through a GET request with the following parameters :  

     

A sample GET request could therefore look like:

  


3. The User Experience

At this point, you’ve forwarded the user to Channel i authorisation page : 

     

Your application doesn’t need to do anything here; OAuth handles authenticating the user and giving them feedback on any errors. 

After successfully entering their credentials, the user will be asked for consent, to authorize your application to access their account. 

After clicking Continue, you’ll receive a response from OAuth, as outlined in the next section. 


4. Handling the Response from Channel i OAuth 

If the user clicked Continue in the previous screen, OAuth will redirect the user to the REDIRECT_URL you specified earlier with a code parameter 

Note: Each generated code will expire after 10 minutes. 

For example, if your redirect URL was https://www.ned.com/starkuser would be redirected to :

 

     

5. Getting the Access Token 

Once your application has completed the above section and got an authorization code, it will now need to exchange the authorization code for an access token from Channel i OAuth. 

To get the access_token, you’ll need to make a POST request to http://channeli.in/oauth/gettoken/ with the following parameters: 

     

An example request in curl looks like : 

     

If everything goes right and the request is successful, you’ll receive a 200 response containing a JSON body like this: 

     

However, if the response is not successful, you’ll receive an error response!  


6. Using the Access Token 

The access_token is the actual string needed to make API requests. Each access_token is valid for 1 monthAfter 30 days, this token cannot be used to get the user info and thus the user will be required to perform  OAuth log-in again.

Now as you have got an access tokenyou can get user info using it. To get the user info, you’ll need to make a POST request to http://channeli.in/oauth/getuserdata/ with the following parameters :

   

An example request in curl looks like : 

     

If everything goes right and the request is successful, you’ll receive a 200 response containing a JSON body like this: 

   


ERROR DESCRIPTION :  


Before using OAuth, go through the Terms and Conditions carefully.