Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/indentno/socialite-provider-vipps
https://github.com/indentno/socialite-provider-vipps
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/indentno/socialite-provider-vipps
- Owner: indentno
- Created: 2020-03-03T20:19:29.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-04T07:51:36.000Z (about 1 year ago)
- Last Synced: 2024-04-20T04:04:27.368Z (9 months ago)
- Language: PHP
- Size: 10.7 KB
- Stars: 5
- Watchers: 3
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Socialite Provider for Vipps
## 1. Installation
```bash
// This assumes that you have composer installed globally
composer require sempro/socialite-provider-vipps
```## 2. Service Provider
Add to app.php:
``` php
'providers' => [
Laravel\Socialite\SocialiteServiceProvider::class,
\SocialiteProviders\Manager\ServiceProvider::class,
];
```## 3. Event Listener
* Add `SocialiteProviders\Manager\SocialiteWasCalled` event to your `listen[]` array in `app/Providers/EventServiceProvider`.
Example:
```php
/**
* The event handler mappings for the application.
*
* @var array
*/
protected $listen = [
\SocialiteProviders\Manager\SocialiteWasCalled::class => [
'\SocialiteProviders\Vipps\VippsExtendSocialite@handle',
],
];
```
## 4. Configuration setupYou 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`.
```php
'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
* [Laravel docs on configuration](http://laravel.com/docs/master/configuration)
* 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
```php
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.```php
$user = Socialite::driver('vipps')->stateless()->user();
```Example for a VippsAuthController:
```php
redirect();
}
// Vipps callback function (VIPPS_REDIRECT_URL in .env)
public function handleCallback()
{
$user = Socialite::driver('vipps')->stateless()->user();
if (!$user) {
//Return error message
}//Do Authentication stuff
}
}
```## Vipps guidelines
* When using Vipps login you need to use the login button svgs provided by Vipps.
Go to [Vipps design guidelines](https://github.com/vippsas/vipps-design-guidelines) for more info.## License
MIT © [Sempro AS](https://www.sempro.no)