lundi 1 mai 2017

How to get protected resource in postman after getting a bearer access token using passport package in laravel 5.4

I am using laravel 5.4. And using oauth2 passport package.

i got a access token and refresh token in post man.

{
  "token_type": "Bearer",
  "expires_in": 31536000,
  "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImE1YTNiODUxZGNlMWQ4MTIxYzI2OWQyMzg1NzU0MzNmYWVkMzU5NmYwZWFmM2VhY2M0ODJmYzQ0YzIzODM1YTY5ODFmZDNhNWQxOGI2NWQ1In0.eyJhdWQiOiIyIiwianRpIjoiYTVhM2I4NTFkY2UxZDgxMjFjMjY5ZDIzODU3NTQzM2ZhZWQzNTk2ZjBlYWYzZWFjYzQ4MmZjNDRjMjM4MzVhNjk4MWZkM2E1ZDE4YjY1ZDUiLCJpYXQiOjE0OTM3MDA4OTMsIm5iZiI6MTQ5MzcwMDg5MywiZXhwIjoxNTI1MjM2ODkzLCJzdWIiOiIxIiwic2NvcGVzIjpbXX0.KJwgqV0aibhiVXUAooCoUcGv17EqayLQFSPR2w5yjxzE4foCpyUDiBmQQ26-UK0CYZxZmjhK14tQhbDLz8GnWHrRja1Wzg13-xuobpFc4kZQ3rmCqP7cP3nRiO7N81zt6YDLV6piQNLhWF68LeIZj3IZ-ezWZY8_D2z_P-ixFmCyHUcxm0FSJ7wOVzYqKENGvu1ckvZ6hdVn5_vTZKcot_hE1iyiEE7Z9lU3rThLcFlmeh00-wZsLHxPka70tz-9gUPV4Q4aabQ_dXvwBDGQ_NQWaDn02tkdXGrCJXpgQDRpnqY_IiqORDmqFYM_8iNs-fSVQOOuJzMg2iUcsrvc_WWgeR9TtN7OuT2dEruhwOtKz5pwIYVD5mfWitRYJevtJY3obzwrNAty9I8WzUM2JR8i1xphfm36uhZnofXpKtm3kABC-1he1pfnsDl-H8I7GVe5i6ArgTpvWBgh0E_H3Ls0C97Y0DMz0iFDGn7gtiIP1TpADMfth7Eg_5Zo1FvHCuma6gAFb7aKi4LyLEDwTMcMEX-TyEiO6AtRpHpk74R9iTKB0bFkepSrkoIx0IGADO_mK6nkGZXTgG_4GOsHA3hbCGYibpHxmjE9n0SfSLVV5OXSqiDB4htvhDgtttfOOLUZRbR9ERParBXXjD-vZFeAtWzBgI0zTau69NKqIig",
  "refresh_token": "LmrHIz+2KVaIDXGPatZqrg4/dPxAOj8tFHNpBuXj+MkEy0C+xtkKc1HWhrH4ePddApXdjzxbJn4MIMqMChDM90ar2gnE97y0KqtX2C5x9XgKKSzn0NvyL8j90H/GyhRT+tds3R8Rt9rQL4NVMsetgS0s6RwfBBnwvT9Ay2NFRNUJgzJh0Z5Kaa69P9fyYPhn5EvX5+rd5eKTahMTFtINLuyN7F/zAELJuSAvTl+4MidiRDtUOoyT/fnB7rqDzpt7osAphRwTHr3nC+xN3tm87436WEurvVoVUFuNDErAvNlUwEMoK/m+Dy1lo+nGVFvbontNH8XmVJmJBYUmf2bGtFJzEQBfdrhWzHl0YXFHUR4l+1xTA0ZEBvonM5Ie/aP53JtQHU/yo1BePLsOuiXVcbmiEYLe7e3WaW5HvQ6TYUpYIx93nsp/0XzUMo+4BNuXzog9x5nUpLOqCK0HoubDJGRL9DP0NzELO7KFw4JZlVlwHhcEqTm/J5i7J/xauuAYfSG4aJWevaUYTSYcvX3rfIZTJUa1cyd4qfG5aMgV2obJcIb6OXjH6UFxMh21Pw86RG2Gst+RaVIoG2okrwUhqkhvJGIjKtoiqmDcbC7ksNm2SsnDsFR83mRXf9Tl/Ca/WRoi4THocNoikKEX4I51Y1frGa/bNDxiOAPdsQAEZOw="
}

Now i want to access user or some other routes from my laravel controller using this bearer access token in postman.

at the same time if anyone access data without using this token, i want show error of 401 (Unauthorized) in json.

Pls Answer Any one know the solution for this question.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire