PHPackages                             digitive/vipps-socialite-provider - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. digitive/vipps-socialite-provider

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

digitive/vipps-socialite-provider
=================================

Vipps OAuth2 Provider for Laravel Socialite

2.0.1(3y ago)1467MITPHPPHP ^8.1

Since Sep 3Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Digitive-NO/vipps-socialite-provider)[ Packagist](https://packagist.org/packages/digitive/vipps-socialite-provider)[ RSS](/packages/digitive-vipps-socialite-provider/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

Socialite Provider for Vipps
============================

[](#socialite-provider-for-vipps)

1. Installation
---------------

[](#1-installation)

```
// This assumes that you have composer installed globally
composer require digitive/vipps-socialite-provider
```

2. Service Provider
-------------------

[](#2-service-provider)

Add to app.php:

```
'providers' => [
    Laravel\Socialite\SocialiteServiceProvider::class,
    \SocialiteProviders\Manager\ServiceProvider::class,
];
```

3. Event Listener
-----------------

[](#3-event-listener)

- Add `SocialiteProviders\Manager\SocialiteWasCalled` event to your `listen[]` array in `app/Providers/EventServiceProvider`.

Example:

```
/**
 * The event handler mappings for the application.
 *
 * @var array
 */
protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        '\SocialiteProviders\Vipps\VippsExtendSocialite@handle',
    ],
];
```

4. Configuration setup
----------------------

[](#4-configuration-setup)

You will need to add vipps to the services configuration file so that after config files are cached for usage in production environment (Laravel command `artisan config:cache`) all config is still available.

#### Add to `config/services.php`.

[](#add-to-configservicesphp)

```
'vipps' => [
    'client_id' => env('VIPPS_CLIENT_ID'),
    'client_secret' => env('VIPPS_CLIENT_SECRET'),
    'redirect' => env('VIPPS_REDIRECT_URI'),
],
```

Remember to whitelist the redirect\_uri in the [Vipps portal](https://portal.vipps.no/). Client ID and secret is also available in the [Vipps portal](https://portal.vipps.no/).

5. Usage
--------

[](#5-usage)

- [Laravel docs on configuration](http://laravel.com/docs/master/configuration)
- Guzzle version 7 or later is required
- You should now be able to use it like you would regularly use Socialite (assuming you have the facade installed):

To initiate the Vipps login, add this to your controller

```
return Socialite::driver('vipps')->redirect();
```

You've now gotten a user token from Vipps in your callback function. Now we need to use the user token to get the phone number of the authenticated user.

```
$user = Socialite::driver('vipps')->stateless()->user();
```

Example for a VippsAuthController:

```
