(Quick Reference)

Login

Basic Login

  • Path : /api/login
  • Parameters :
    • username : a valid email address
    • password : password
  • REST Method : POST
  • Request :

http://indiabiodiversity.org/api/login?username=emailAddress&password=password
  • Response :
    • on success

{
    "success": true,
        "status": 200,
        "msg": "Successfully logged in",
        "model": {
            "id": 1064,
            "username": "sravanthi@strandls.com",
            "access_token": "2meoaj8q6bnmdt2mjscjpee8ok4305jc",
            "roles": [
                "ROLE_USER"
                ]
        }
}
    • in case of error

a 401 unauthorized status code is sent in case of missing credentials

{
    'error':'400', 
    'message':'Username and/or password parameters are missing.'
}
in case of incorrect credentials
{'success':false, 'status':'401', 'error':'401', 'msg':'Bad credentials'}
in case of incorrect method
{
    "error": "405",
    "message": "GET HTTP method is not supported."
}

OAuth Login

  1. Login to oauth service providers by sending a request at the respective urls.

Facebook

  • Path : /api/oauth/callback/facebook
  • Parameters :
    • access_token : valid fb access_token
  • REST Method : GET
  • Request :

http://indiabiodiversity.org/api/oauth/callback/facebook?access_token=CAAE7wX9joZBUBAP6LcCLyelAGFA3X6YgZBZBAVj9NMSv7ZC6ZCTCMr3ce4PBMZARJzcP5tQ3i0NoxVbPc7ghmjmrYXaZAHnl1MLKh2lkVaDA6ClU1QLTMZC1tMfCzmhVvJUaxV2lYsypG2zkJ1WRE68oebnifeAmqi1p1Nca6jlZB8lGZBZCoKy7JyV
  • Response :
    • on success

{
    "success": true,
        "status": 200,
        "msg": "Successfully logged in",
        "model": {
            "id": 1184,
            "token": "hkdgm6jrfg2trkmj66m60js6vd6rsscb",
            "format": null
        }
}
    • in case of error

{
    "success": false,
        "status": 500,
        "msg": "No access token",
        "errors": []
}

Google

  • Path : /api/oauth/callback/google
  • Parameters :
    • access_token : valid fb access_token
  • REST Method : GET
  • Request :

http://indiabiodiversity.org/api/oauth/callback/google?access_token=ya29.NQAgcZ76JSRLPiEAAAAyQqVUs71Vg5mwee3MZYI8oYKkTDToIPLRabO42Aamki3LSBWmLTfYw49PqbRIlBs&token_type=Bearer&expires_in=3600
  • Response :
    • on success

{
    "success": true,
        "status": 200,
        "msg": "Successfully logged in",
        "model": {
            "id": 1184,
            "token": "hkdgm6jrfg2trkmj66m60js6vd6rsscb",
            "format": null
        }
}
    • in case of error

{
    "success": false,
        "status": 500,
        "msg": "Failed to retrieve data / failed code : 401 and body : {n "error": {n  "errors": [n   {n    "domain": "global",n    "reason": "authError",n    "message": "Invalid Credentials",n    "locationType": "header",n    "location": "Authorization"n   }n  ],n  "code": 401,n  "message": "Invalid Credentials"n }n}n",
        "errors": []
}