title: Integration of Spring Oauth2 implementation with the HTML front end using javascript
body: <p>I am implementing spring oauth2 for securing my rest api. Basically i am limiting the use of rest api to particular users rather then limiting to every users.</p>
  
  <p>I had implemented the backend and secured my api using spring oauth2.</p>
  
  <p>I am following this steps:<br/>
  1)Send the GET request with the five parameters.<br/><br/>
  <strong>localhost:8080/SpringRestSecurityOauth/oauth/token?grant_type=password&amp;client_id=Awyi123nasdk89&amp;client_secret=asdj39m32@#$s&amp;username=rahul@gmail&amp;password=rahul@9831</strong><br/><br/>
  2) Server validates the user with the help of spring security and return the json response with access code.<br/>
  <br/><strong>{
  "access_token": "22cb0d50-5bb9-463d-8c4a-8ddd680f553f",<br/>
  "token_type": "bearer",<br/>
  "refresh_token": "7ac7940a-d29d-4a4c-9a47-25a2167c8c49",<br/>
  "expires_in": 119<br/>
  }</strong><br/><br/>
  3)I access protected resources by passing this access token as a parameter, the request goes something like this:<br/><br/>
  <strong>localhost:8080/SpringRestSecurityOauth/api/users/?access_token=8c191a0f-ebe8-42cb-bc18-8e80f2c4238e</strong> <br/>
  <br/>4) In case the token is expired, user needs to get a new token using its refreshing token that was accepted in step(2). A new access token request after expiration looks something like this:<br/>
  <br/><strong>localhost:8080/SpringRestSecurityOauth/oauth/token?grant_type=refresh_token&amp;client_id=restapp&amp;client_secret=restapp&amp;refresh_token=7ac7940a-d29d-4a4c-9a47-25a2167c8c49</strong> <br/></p>
  
  <p>All the above step are working fine. Now i need to implement this on my client side. So that a particular client can access this call. I am using HTML/CSS as client side technology.</p>
  
  <p>How client can get the access token? Should it be stored in the browser local storage? Or it should be generated every time the rest call is been made?</p>
  
  <p>Any example would help me to proceed further.</p>