Authentications

Authentications are tokens bound to a user or the application. When accessing the auth route an authentication is created and updated each time the user logs in with that provider.

You can fetch authentications off a UserInterface instance using the authentication method:

$authentication = $user->authentication($provider);

You can also fetch the application authentication directly off a ProviderExtension instance.

$authentication = $addons->get('facebook_provider')->authentication();

Using the authentication you can then access all the tokens and expiration:

$authentication->getAccessToken();
$authentication->getRefreshToken();
$authentication->getExpiresAt();
$authentication->getSecret(); // For OAuth1

The provider() method will return the authenticated provider extension. You can access the provider user this way:

$authentication->provider()->user()->name
user().authentication('facebook').provider.user.name