title: Fetch OAuth token from ebay api
body: <p>I'm developing a web application to to fetch data from '<a href="https://api.ebay.com/sell/analytics/v1/traffic_report" rel="nofollow noreferrer">https://api.ebay.com/sell/analytics/v1/traffic_report</a>'</p>
  
  <p>I've a ebay developer account with 
  ClientId: MyClientId
  ClientSecret: MyClientSecret
  AppId: MyAppId</p>
  
  <p>To achive this, I need a OAuth token</p>
  
  <p>To get OAuth Token I do the following steps.</p>
  
  <p>I browse the url bellow</p>
  
  <p><a href="https://signin.ebay.com/authorize?client_id=MyClientId&amp;redirect_uri=RuName&amp;response_type=code&amp;state=analytics&amp;scope=https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.analytics.readonly" rel="nofollow noreferrer">https://signin.ebay.com/authorize?client_id=MyClientId&amp;redirect_uri=RuName&amp;response_type=code&amp;state=analytics&amp;scope=https%3A%2F%2Fapi.ebay.com%2Foauth%2Fapi_scope%2Fsell.analytics.readonly</a></p>
  
  <p>It goes to </p>
  
  <p><a href="https://signin.ebay.com/ws/eBayISAPI.dll?VAppJanessa&amp;reqinput=reqinput" rel="nofollow noreferrer">https://signin.ebay.com/ws/eBayISAPI.dll?VAppJanessa&amp;reqinput=reqinput</a> - auto generate</p>
  
  <p>after sign in   it redirects to 'Grant application access to MySiteDisplayName' page.</p>
  
  <p>After I Agree it redirects to '<a href="https://my_site.com/?state=analytics&amp;code=code" rel="nofollow noreferrer">https://my_site.com/?state=analytics&amp;code=code</a>'
  I've preapared a post request after collecting the code </p>
  
  <p>I've executed the post request using POSTMAN  like bellow</p>
  
  <p>Post URL: '<a href="https://api.ebay.com/identity/v1/oauth2/token" rel="nofollow noreferrer">https://api.ebay.com/identity/v1/oauth2/token</a>'</p>
  
  <p><strong>Headers</strong>:</p>
  
  <p>cache-control: no-cache</p>
  
  <p>Content-Type: application/x-www-form-urlencoded</p>
  
  <p>Authorization: Basic Base64 value of 'MyClientId:MyClientSecret'</p>
  
  <p><strong>Body</strong>:</p>
  
  <p>grant_type: authorization_code</p>
  
  <p>redirect_uri: RuName</p>
  
  <p>code: code returned from previous request</p>
  
  <p>After post request I've got the result </p>
  
  <p>{
      "error": "invalid_grant",
      "error_description": "the provided authorization grant code is invalid or was issued to another client"
  }</p>
  
  <p>Please tell me what is missing or wrong.</p>