Search code examples
phplaravel-5google-oauthlaravel-socialite

Rest API Authentication using Token from mobile application


I am building a backend rest api for a android application. It authenticates user and sends the token in Authorization HEADER. I am extracting the token from header in a custom middleware . Now I tried to check with Socialite whether it provides a way for me to get the user by token. If user does not exist we will create a user else send response as success to android application.

Now in Socialite I cannot implement specific method getUserByToken($token) since its protected.

I am not proficient with laravel. Can some one guide me?

Thanks, Pavan


Solution

  • Socialite is not an authentication library but a library that provides and interface to Oauth for many social networks. In order to do what you want you should look at the auth library http://laravel.com/docs/5.0/authentication and I guess that the getUserByToken should go to your User model.