Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News:
Using the Google API with Socialite
Apr 11, 2017 @ 09:47:36

On the Laravel News site there's a new tutorial posted showing you how to use the Socialite package with the Google API to connect a user's account and get a list of their contacts.

When I start a project that requires users to log in using their Google accounts, I immediately turned to Laravel Socialite. Socialite is one of Laravel’s official packages, but it is clear it only handles user authentication, making its use not as dynamic as I had hoped it would be. While I needed users to log in, I also needed to get a list of their Google Contacts. In this post, I’ll show you how I was able to query a list of contacts from Google’s People API and keep using Socialite.

They start with a basic guide to creating an application on the Google API Console and what information you'll need (credentials) to allow your application to connect. Then, using the Google API Client for PHP and the functionality built into Socialite they create the approval flow and how to handle refresh tokens should your token expire.

tagged: tutorial laravel socialite contacts google api token

Link: https://laravel-news.com/google-api-socialite

SitePoint PHP Blog:
Easily Add Social Logins to Your App with Socialite
Apr 06, 2017 @ 11:57:20

In the latests post to the SitePoint PHP blog *Reza Lavaryan * shows you how to use Socialite to add social logins to your Laravel application. Unfortunately the Socialite package cannot be used outside of Laravel.

Laravel Socialite is a package developed to abstract away any social authentication complexities and boilerplate code into a fluent and expressive interface.

Socialite only supports Google, Facebook, Twitter, LinkedIn, Github, and Bitbucket as OAuth providers. They won’t be adding any others to the list, however, there’s a community-driven collection called Socialite Providers, which contains plenty of unofficial providers for Socialite. More on this in the next section.

He starts off with the generation of the standard "auth" handling in Laravel using the "make:auth" artisan command. He then uses Composer to pull in the Socialite package and updates the Laravel configuration to enable it. Next up is the configuration for the different social services and migrations you'll need to make for database changes (on users table and adding a new "social logins" table). Next come the updates to the models, controllers, routes and providers to hook Socailite into the authentication process. To illustrate the overall flow, they show how to hook the application into GitHub as an auth source. The post finishes out talking about custom providers, using one to authenticate against Spotify and how to create your own.

tagged: social login socialite laravel package tutorial

Link: https://www.sitepoint.com/easily-add-social-logins-to-your-app-with-socialite/

Barry vd. Heuvel:
OAuth in Javascript Apps with Angular and Lumen, using Satellizer and Laravel Soci
Jul 22, 2015 @ 09:51:49

Barry vd. Heuvel has a post to his site sharing a step by step guide to setting up OAuth in a Lumen+AngularJS application via Socialite and Satellizer (an AngularJS library for OAuth and token based authentication).

In the last few weeks, Socialite was a popular topic to blog/tweet about. Coincidentally, I also needed Socialite for a project. But in my case, I wanted to use it in an Angular app, distributed using Cordova (Phonegap) as hybrid app on Android/iOS. There were some examples, but I couldn’t find much about it at the time. A few people asked to share my experience about it, so here it is!

He starts by linking to all of the tools you'll need to help get some background on them including a helpful guide to installing Satellizer. He then goes over the flow of the entire process, from the initial call from the AngularJS side to authenticate, through the backend Lumen/Socalite/Satellizer handling and then back out to the Javascript where the token is then stored. With this established, he gets into the implementation details starting with the Lumen code to make the API request to GitHub then working with the JWT tokens and responding back to the AngularJS frontend with the result.

tagged: angularjs lumen framework tutorial socialite satellizer oauth jwt token

Link: http://barryvdh.nl/laravel/lumen/angular/2015/07/19/oauth-in-javascript-apps-with-angular-lumen-using-satellizer-laravel-socialite/

Binary Studio Blog:
Definitive Guide On Creating Custom Providers For Laravel OAuth2 Authorization
May 26, 2015 @ 12:45:12

A new guide has been posted showing you how to create custom OAuth2 providers for your Laravel application. In this case they wanted to hook the application in via Socialite to the VK social network but needed a custom connector to make it happen.

First of all let’s say that social authorization is very popular and frankly speaking it’s really handy tool. Surfing internet we can see a lot of sites and services which offer login with Facebook, Twitter, Google and other social networks. [...] If you’re building your website in PHP using Laravel, probably you’ve noticed Socialite which provides OAuth / OAuth 2 authentication with Facebook, Twitter, Google, and GitHub. The most famous social network which provides OAuth2 authentication in Russian segment of the internet is vk. But there is a lack of such connector (provider) in Socialite library. Actually it’s not a hard problem, so let’s build new VkProvider on top of Socialite’s components.

He starts with a brief look at the typical OAuth2 authentication flow between the social network and your application. From there it gets more vk.com specific. He shows how to set up the custom application on their side, updating your configuration with the credentials and installing Socialite. He then implements a "VkProvider" defining the required methods based on the interface. He then registers it as a "SocialiteServiceProvider" and uses it in a "login" request route.

tagged: oauth2 guide custom provider laravel socialite tutorial vkcom russian

Link: http://binary-studio.com/2015/05/25/laravel-oauth2/