Codechef APi issue with Postman

Hi,
I also having trouble in using codechef api’s from postman, before accessing any api you must be access token. To get access token I followed below process.

  1. authorization screen for postman collection First Image
  2. entered valid details needed for to get access token Second image
  3. redirected to login screen of code chef Third Image
  4. logged in and authorized the application Fourth image
  5. Then it will throw error stating that unsupported media type 415. Fifth Image

The reason behind this is content-type for POSt request id set to “application/x-www-form-urlencoded” but it should be application/json as stated in documentation.

My question is can you suggest a work-around to use it or proper steps to use it thourgh curl

Hi,

your_client_id = your app’s client id.

your_client_secret = your app’s client secret.

your_redirect_uri = URL of your server to receive authorization token.

state_code = some random code for security.

If you want to use curl then

1.) Run this URL in your browser (https://api.codechef.com/oauth/authorize?response_type=code&client_id=your_client_id&state=xyz&redirect_uri=your_redirect_uri)
This will show a pop up window to login and select your scopes. This process will be done on client side.

2.) After client authentication, you will receive a code on your_redirect_uri. This code is Authorization code(your_authorization_code). Use this code to get access token for the user using this curl on your server.

curl -X POST https://api.codechef.com/oauth/token -H ‘content-Type: application/json’ -d ‘{“grant_type”: “authorization_code”,“code”: “your_authorization_code”,“client_id”:“your_client_id”,“client_secret”:“your_client_secret”,“redirect_uri”:“your_redirect_uri”}’

3.) Now you will get accessToken and refreshToken for that user on your server.

Thanks for the response