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

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

sempro/socialite-provider-vipps
===============================

Vipps OAuth2 Provider for Laravel Socialite

3.0.0(1y ago)72.5k↓33.3%4MITPHPPHP ^8.0CI passing

Since Mar 3Pushed 1y ago3 watchersCompare

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

READMEChangelog (1)Dependencies (1)Versions (9)Used By (0)

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

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

> Custom provider for using Vipps with Laravel Socialite. This package requires laravel socialite in your project.

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

[](#1-installation)

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

2. Event Listener
-----------------

[](#2-event-listener)

### Laravel 11+

[](#laravel-11)

In Laravel 11, the default `EventServiceProvider` provider was removed. Instead, add the listener using the `listen` method on the `Event` facade, in your `AppServiceProvider` `boot` method.

```
Event::listen(function (\SocialiteProviders\Manager\SocialiteWasCalled $event) {
    $event->extendSocialite('vipps', \Indent\SocialiteProviderVipps\Provider::class);
});
```

Laravel 10 or below Configure the package's listener to listen for `SocialiteWasCalled` events. Add the event to your `listen[]` array in `app/Providers/EventServiceProvider`. See the [Base Installation Guide](https://socialiteproviders.com/usage/) for detailed instructions.

```
protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // ... other providers
        \Indent\SocialiteProviderVipps\VippsExtendSocialite::class . '@handle',
    ],
];
```

3. Add configuration to `config/services.php`
---------------------------------------------

[](#3-add-configuration-to-configservicesphp)

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

    // Optional. Can be provided for interacting with vipps test api.
    'base_url' => 'apitest.vipps.no',

    // Optional. Can be added in order to request more data.
    // (See link for list of scopes: https://api.vipps.no/access-management-1.0/access/.well-known/openid-configuration)
    'scopes' => [
        'name',
        'email',
    ],
],
```

Remember to whitelist the redirect\_uri in the Vipps portal.

4. Usage
--------

[](#4-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')->user();
```

Example for a VippsAuthController:

```
