title: Spring Authentication against an external API
body: <p>I need to authenticate User against an external API where i need to pass the <strong>username</strong> and <strong>password</strong>. The API is a <strong>REST web service</strong> which will return be a <strong>json object</strong>. Now I need to extract the "<strong>auth_token</strong>"(an element in json) and set it in user context for further requests <strong>since other requests need this auth_token to be set into the header</strong> . There is no authentication logic need to be written at our end. All the login logic is taken care at API's end.
  This is how the returned JSON Object look like:</p>
  
  <pre><code>{
    "success" : true,
    "auth_token" : "a2xvv-mqe_sV_Lhsggkd3Q",
    "email" : "****.***@***.com",
    "role" : "admin",
    "time_zone" : "Mumbai",
    "user_key" : "b3222tf92d",
    "sign_in_count" : 208,
    "organisation" : {
      "name" : null,
      "organisation_key" : null,
      "license" : {
        "license_key" : "tebde23823t5a76828e2et8683fd3b33e2eat5fb"
      }
    }
  }
  </code></pre>
  
  <p>How to achieve this functionality in spring security.
  It would be a great help if you provide me the steps with example if possible.</p>