Reference :http://blog.tankist.de/blog/2013/07/17/oauth2-explained-part-2-setting-up-oauth2-with-symfony2-using-fosoauthserverbundle/
  


::Step1::  Create client_id and client_secret using command line
----------------------------------------------------------------------------
  
php app/console acme:oauth-server:client:create --redirect-uri="http://gosh.com/" --grant-type="authorization_code" --grant-type="password" --grant-type="refresh_token" --grant-type="token" --grant-type="client_credentials"
 
O/p: Added a new client with public id 5_5mrt0sd6cs4c8gg8sggssowkogco4okw448gock880s084kwc0,, secret 2lwec37xnbcwwss4g8gs0ks84cwokckwk8sg8k448o48scs0o0 
  
  

::Step2:: Generate Token
-------------------------------------------------------------------------------------
Execute following url
YOUR_HOST/app_dev.php/api/v1/authorize-token?client_id=5_5mrt0sd6cs4c8gg8sggssowkogco4okw448gock880s084kwc0&client_secret=2lwec37xnbcwwss4g8gs0ks84cwokckwk8sg8k448o48scs0o0&grant_type=password&username=support@officebeacon.com&password=123456

Other client_id:6_1j86gvq4nti8ggog0okgg8wwcccko0ckok8cw00g0w4ss8g00w 
and client_secret:3ifc7bnjgsmc4gw80os808kg4gs48co0co4w8g0040w8g4wgwk

O/P:
{
  "access_token": "ODMzZmI5ZDc1YTRjZmEwYzkxYTQ0ZTRlYzc4M2Y2NGQzZGQwMjdkOGFhOGJmZTBlNGJlYjZkNjIxOTM2ZjJlYw",
  "expires_in": 3600,
  "token_type": "bearer",
  "scope": user,
  "refresh_token": "MjAxNmQ5NjE1MjU5OWQxNGZlZmYwYzgyN2I4YWEyYzg4YWJjN2UwNjJhNTQ4ZmY4NDI5Nzk5N2IxNGJmOTA1Nw",
  "user": {"email":"support@officebeacon.com","id":"1","firstName":null,"lastName":null}
}



Step3: Use Token
----------------------------------------------------
User your token as ?access_token=ACCESS_TOKEN




Step4: To regenerate or refresh token
------------------------------------------------------------------
PROVIDER_HOST/api/v1/authorize-token?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=refresh_token&refresh_token=REFRESH_TOKEN
ex. PROVIDER_HOST/api/v1/authorize-token?client_id=5_5mrt0sd6cs4c8gg8sggssowkogco4okw448gock880s084kwc0&client_secret=2lwec37xnbcwwss4g8gs0ks84cwokckwk8sg8k448o48scs0o0&grant_type=refresh_token&refresh_token=MjAxNmQ5NjE1MjU5OWQxNGZlZmYwYzgyN2I4YWEyYzg4YWJjN2UwNjJhNTQ4ZmY4NDI5Nzk5N2IxNGJmOTA1Nw
O/P:
{
"access_token":"YzlkMGJkNjU0YmExNDc5Njk0OTI1OGY1ZWUxNjYyMWYwNThjYTFiMDVmMjFiMTJmYmFjYmQxMzY4YjQ4NDFmMw",
"expires_in":3600,
"token_type":"bearer",
"scope":"user",
"refresh_token":"MzlhN2RmOGI3YTYzNjM0ZDQ0ZDdlZTNhNzBkMzQ3OGFiM2IyMWJkNzY3Y2Y0ZWZjY2Q1YjNjYTNhOGRkNTI1ZQ"
}


==============================================
Types of errors
==============================================
1. For invalid token
{"error":"invalid_grant","error_description":"The access token provided is invalid."}

2. Expired token
{"error":"invalid_grant","error_description":"The access token provided has expired."}

3. Without token
{"error":"access_denied","error_description":"OAuth2 authentication required"}

4. Invalid refresh token
{"error":"invalid_grant","error_description":"Invalid refresh token"}
