# User/Geo-Based Consent using APIs
source: https://developer.mastercard.com/consent-management/documentation/tutorials-and-guides/user-consents-tutorial/index.md

## Overview {#overview}

This tutorial uses the reference app to create a user-based consent using the Consent Management \& Enrollment APIs. Unlike card-based consent, user-based consent is tied to a user identity (name, postal code, and optional email or phone) rather than a specific card.

The source code is available in both Java and Python. Download the reference app from the [Reference App](https://developer.mastercard.com/consent-management/documentation/developer-tools/reference-app/index.md) page.

## Prerequisites {#prerequisites}

* Java 17+
* Apache Maven 3.3+
* Mastercard OAuth1 signing library
* Mastercard client encryption library
* Python 3.6+
* pip
* Mastercard OAuth1 signing library
* Mastercard client encryption library

For both languages, you also need:

* A [Mastercard Developers](https://developer.mastercard.com/dashboard) account with a project that includes the Consent Management \& Enrollment APIs
* OAuth signing key (`.p12`), consumer key, and encryption certificate (`.pem`) from your project

For detailed setup steps, see the [Quick Start Guide](https://developer.mastercard.com/consent-management/documentation/quick-start-guide/index.md).

## Application Configuration {#application-configuration}

1. Download the reference app from the [Reference App](https://developer.mastercard.com/consent-management/documentation/developer-tools/reference-app/index.md) page.

2. Copy the `.p12` and `.pem` files to `src/main/resources`.

3. Update `src/main/resources/application.properties`:

   ```properties
   signing.consumerKey=<your consumer key>
   signing.pkcs12KeyFile=<your .p12 filename>
   signing.keyAlias=<your key alias>
   signing.keyPassword=<your keystore password>
   client.encryption.pemFile=<your .pem filename>
   ```

1. Download the reference app from the [Reference App](https://developer.mastercard.com/consent-management/documentation/developer-tools/reference-app/index.md) page.

2. Copy the `.p12` and `.pem` files to `app/config/`.

3. Update `app/config/application.properties`:

   ```properties
   signing.consumerKey=<your consumer key>
   signing.pkcs12KeyFile=<your .p12 filename>
   signing.keyAlias=<your key alias>
   signing.keyPassword=<your keystore password>
   client.encryption.pemFile=<your .pem filename>
   ```

Note: In a production application, store keys and passwords securely, for example in an HSM.

## Build and Run {#build-and-run}

* Java
* Python

```java
mvn clean compile
mvn spring-boot:run
```

```bash
pip3 install -r requirements.txt
FLASK_APP=app/main python3 -m flask run -p 8081
```

Open <http://localhost:8081> in your browser. The home page displays three API cards.

![Reference app home page showing the three API cards](https://static.developer.mastercard.com/content/consent-management/img/ref-app-home.png)

Select **User Consent Management API** to begin the user consent flow. To walk through the consent flow using this demo, go to [Create User Consents](https://developer.mastercard.com/consent-management/documentation/tutorials-and-guides/user-consents-tutorial/create-consents/index.md).
