Skip to main content

A configurable Django Allauth provider for Vipps Login.

Project description

Django Allauth Vipps Provider

PyPI version License: MIT CI/CD Tests

A complete django-allauth provider for Vipps Login, supporting both traditional web and modern API (dj-rest-auth) authentication flows.

This package provides a configurable, reusable Django app that allows users to sign in to your project using their Vipps account, making it easy to integrate Norway's most popular payment and identity solution.

Features

  • Integrates seamlessly with django-allauth's social account framework.
  • Supports API-first authentication flows via dj-rest-auth.
  • Configurable for both Vipps Test and Production environments via standard settings.
  • Correctly handles Vipps' required client_secret_basic authentication method for REST APIs.
  • Fully tested and documented for a "drop-in" experience.

1. Installation & Setup

Step 1: Install the Package

pip install django-allauth-vipps

(Or poetry add django-allauth-vipps if you use Poetry)

Step 2: Update INSTALLED_APPS

Add vipps_auth to your INSTALLED_APPS in your Django settings.py.

# settings.py

INSTALLED_APPS = [
    # ...
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'vipps_auth',
]

SITE_ID = 1
AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.ModelBackend',
    'allauth.account.auth_backends.AuthenticationBackend',
]

Step 3: Configure the Provider

Configure the provider using django-allauth's standard SOCIALACCOUNT_PROVIDERS setting in your settings.py.

# settings.py
import os

SOCIALACCOUNT_PROVIDERS = {
    'vipps': {
        # Configure credentials using environment variables.
        'APPS': [
            {
                'client_id': os.getenv('VIPPS_CLIENT_ID'),
                'secret': os.getenv('VIPPS_CLIENT_SECRET'),
                'key': ''
            }
        ],

        # --- General Provider Settings ---
        'TEST_MODE': False, # Set to True for development/testing
        'VERIFIED_EMAIL': True,
        'EMAIL_VERIFIED_REQUIRED': True,
        'SCOPE': [
            'openid',
            'name',
            'email',
            'phoneNumber',
        ],
    }
}

Important: For credentials, either use the APPS key in settings.py (recommended) or create a SocialApp in the Django Admin. Using both for the same provider will cause an error.

Step 4: Configure on Vipps Developer Portal

  1. Log in to the Vipps MobilePay Developer Portal.
  2. Get your Client ID and Client Secret.
  3. Set the Token endpoint authentication method to client_secret_basic.
  4. Add your Redirect URI (https://yourdomain.com/accounts/vipps/login/callback/ for web flows, or your frontend URL for API flows).

Step 5: Run Migrations

python manage.py migrate

2. Usage

For Traditional Django Websites

Use the provider_login_url template tag.

{% load socialaccount %}
<a href="{% provider_login_url 'vipps' %}">Log In with Vipps</a>

For REST APIs (with dj-rest-auth)

When using dj-rest-auth, you must use the custom VippsOAuth2Client provided by this package to ensure the correct authentication method (client_secret_basic) is used.

In your project's urls.py, create your login view like this:

# your_project/urls.py
from django.urls import path
from dj_rest_auth.registration.views import SocialLoginView
from vipps_auth.views import VippsOAuth2Adapter
from vipps_auth.client import VippsOAuth2Client # <-- Import the custom client

# This view connects dj-rest-auth to our Vipps adapter
class VippsLoginAPI(SocialLoginView):
    adapter_class = VippsOAuth2Adapter
    client_class = VippsOAuth2Client  # <-- Use the custom client here
    callback_url = "YOUR_FRONTEND_CALLBACK_URL" 

urlpatterns = [
    # ... your other urls
    path("api/v1/auth/vipps/", VippsLoginAPI.as_view(), name="vipps_login_api"),
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_allauth_vipps-0.2.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_allauth_vipps-0.2.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file django_allauth_vipps-0.2.1.tar.gz.

File metadata

  • Download URL: django_allauth_vipps-0.2.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.6 Linux/5.4.0-204-generic

File hashes

Hashes for django_allauth_vipps-0.2.1.tar.gz
Algorithm Hash digest
SHA256 857aa7ba1f2cc9a5ce274a8295b661e374bd4c8dce0e53c2c28c71c3eec65a52
MD5 3659d8593c694b100bba3ed7f3a9b7bd
BLAKE2b-256 644f1517e39ff70fd77bb3357f428d5049daf6bcf65557334fa321f413c4f8fa

See more details on using hashes here.

File details

Details for the file django_allauth_vipps-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: django_allauth_vipps-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.6 Linux/5.4.0-204-generic

File hashes

Hashes for django_allauth_vipps-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d553657ebf6a718f5ee9551da154264b03ec710c0e3195a8a551e67a64e73c10
MD5 a027f0b8194e7903f06627ac1dc63a9c
BLAKE2b-256 153065ee176b1ceb2c06ab8d3152d0b2c0a94b146a6a3faefbca068bf66d4cf3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page