> **Description:** Enable easy login and account creation using Vipps MobilePay.

# Login

Choose your login scenario:

- User-initiated - Customer initiates login from your website or mobile app
- Merchant-initiated - You trigger login using customer's phone number (ideal for in-store enrollment)

## Ready to build?

Use the Login API to implement either login scenario.

[Open Login API](https://developer.vippsmobilepay.com/docs/APIs/login-api/README.md)

## Login from website or app

Let customers authenticate and share their profile information with your service using Vipps MobilePay instead of traditional usernames and passwords.

Flow diagram: 5-step login process. (1) User chooses to log in with Vipps or MobilePay on merchant site. (2) If required, user enters phone number on landing page or is taken directly to the app. (3) User confirms login in the app. (4) User gives consent to share information with the merchant. (5) User is logged in on the merchant's site.

1. **User initiates login** - Customer clicks *Log in with Vipps* or *Log in with MobilePay* on your website or app.
1. **Authentication** - On desktop, user enters phone number on landing page. On mobile, app-switch happens automatically.
1. **Confirm in app** - User confirms login in the Vipps or MobilePay app (can choose to be remembered for faster future logins).
1. **Consent to share** - User consents to share requested information (name, email, phone, address) with your service.
1. **User logged in** - User is authenticated and returned to your site with their profile information.

**Seamless for returning users**

If a user has previously logged in and chose *Remember me in browser*, they can log in without opening the app on subsequent visits from the same browser.

View sequence diagram

Login flow from website

```mermaid
sequenceDiagram
    autonumber
    actor U as User
    participant M as Merchant
    participant Login as Login API
    participant App as Vipps/MobilePay App

    U->>M: Click "Log in with Vipps/MobilePay"
    M->>Login: Initiate login request
    Login->>U: Redirect to landing page / app switch
    U->>App: Enter phone number (if needed) and open app
    App->>U: Confirm login
    U->>App: Give consent to share information
    App->>Login: Return authorization code
    Login->>M: Redirect user back to merchant
    M->>Login: Exchange code for tokens
    Login->>M: Return access token and user info
    M->>U: User logged in
```

  User clicks "Log in with Vipps/MobilePay" on the merchant site.
  Merchant initiates a login request with the Login API.
  Login API redirects to the landing page or switches to the app.
  User enters their phone number if needed and opens the app.
  App prompts user to confirm login.
  User gives consent to share information.
  App returns the authorization code to the Login API.
  Login API redirects the user back to the merchant.
  Merchant exchanges the code for tokens with the Login API.
  Login API returns the access token and user info to the merchant.
  User is logged in.

## Merchant-initiated login

Trigger a login flow directly on the customer's device using their phone number. Perfect for in-store customer enrollment and identity verification at point of sale.

Flow diagram: 5-step merchant-initiated login process. (1) Merchant initiates login based on user's phone number. (2) User gets a push notification and opens the app. (3) User confirms login in the app. (4) User gives consent to share information with the merchant. (5) User gets confirmation in the app or on merchant's site.

1. **Get phone number** - Ask customer for phone number (verbally, manual entry, or scan their personal QR code).
1. **Initiate login** - Send login request to customer's device using Login API.
1. **Push notification** - Customer receives push notification and opens Vipps or MobilePay app.
1. **Confirm in app** - Customer confirms login and consents to share information with your service.
1. **Complete enrollment** - Customer is enrolled in your system with their verified information.

View sequence diagram

Merchant-initiated login flow

```mermaid
sequenceDiagram
    autonumber
    actor C as Customer
    participant M as Merchant/POS
    participant QR as QR API
    participant Login as Login API
    participant App as Vipps/MobilePay App

    C->>M: Provide phone number
    M->>Login: Initiate login with phone number
    Login->>App: Send push notification
    C->>App: Open app and view login request
    App->>C: Display consent screen
    C->>App: Confirm and give consent
    App->>Login: Return authorization code
    Login->>M: Poll for completion, receive tokens
    M->>Login: Get user info
    M->>M: Enroll customer in system
```

  Customer provides their phone number.
  Merchant initiates login with the customer's phone number via the Login API.
  Login API sends a push notification to the Vipps or MobilePay app.
  Customer opens the app and views the login request.
  App displays the consent screen to the customer.
  Customer confirms and gives consent.
  App returns the authorization code to the Login API.
  Merchant polls for completion and receives tokens from the Login API.
  Merchant retrieves user info from the Login API.
  Merchant enrolls the customer in the system.

## Implementation resources

- [Login API overview](https://developer.vippsmobilepay.com/docs/APIs/login-api/README.md) - Choose a login flow and find the main integration resources
- [How it works: Login from mobile](https://developer.vippsmobilepay.com/docs/APIs/login-api/how-it-works/login-from-mobile.md)
- [How it works: Login from desktop](https://developer.vippsmobilepay.com/docs/APIs/login-api/how-it-works/login-from-desktop.md)
- [How it works: Merchant-initiated login](https://developer.vippsmobilepay.com/docs/APIs/login-api/how-it-works/merchant-initiated-login-howitworks.md)
- [Login API quick start](https://developer.vippsmobilepay.com/docs/APIs/login-api/login-api-quick-start.md) - Make your first login integration
- [Login API guide](https://developer.vippsmobilepay.com/docs/APIs/login-api/api-guide/README.md) - Learn about scopes, tokens, and API features

> **Full site overview:** For every page in this documentation, read [https://developer.vippsmobilepay.com/llms.txt](https://developer.vippsmobilepay.com/llms.txt).
