PHPackages                             happyonlinegr/socialite-provider-vipps - 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. happyonlinegr/socialite-provider-vipps

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

happyonlinegr/socialite-provider-vipps
======================================

Vipps Provider for Laravel Socialite

06PHP

Since Jul 25Pushed 3y agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

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

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

Installation
------------

[](#installation)

```
composer require happyonlinegr/socialite-provider-vipps
```

Service Provider
----------------

[](#service-provider)

Add to `app.php`:

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

Event Listener
--------------

[](#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',
    ],
];
```

Configuration setup
-------------------

[](#configuration-setup)

You will need to add an entry 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.

5. Usage
--------

[](#5-usage)

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:

```
