Skip to content
Last updated

Authentication and Authorization Guide

Welcome to the Wallapop Connect API authentication guide! Here, youโ€™ll learn how to securely integrate your application using the OAuth 2.0 Authorization Code Flow with PKCEโ€”a modern, secure way to handle authentication. This method ensures your app communicates safely with Wallapop's resource server while following industry best practices from the OAuth 2.0 Security Best Current Practice RFC.

To make life easier, we highly recommend using an OAuth 2.0 client library to handle the heavy lifting for you.


How OAuth 2.0 Authorization Code Flow with PKCE Works

Hereโ€™s a high-level overview of what happens when a user logs in:

UserYour ApplicationWallapop Auth ServerWallapop ServerGenerate Code Verifier and Code ChallengeClick loginRequest authorization code with Code ChallengeRedirect to login/authorization promptAuthenticate and consentReturn authorization codeExchange authorization code and Code Verifier for tokensIssue access and refresh tokensUse access token to request resourcesReturn requested resourcesUserYour ApplicationWallapop Auth ServerWallapop Server

Setting Up Your OAuth Integration

๐Ÿ”— Redirect URI

The redirect_uri tells Wallapop where to send the user after login. It should be an endpoint in your app, like /callback, where your app will handle the authorization code.

๐Ÿ”‘ Client ID and Secret

Wallapop provides a client_id (public) and a client_secret (private). You'll need these to authenticate your app.

๐Ÿ” PKCE Code Verifier & Code Challenge

To access Wallapop resources, you need an access token obtained by exchanging an authorization code.

Since we're using PKCE (Proof Key for Code Exchange), the first step is for your app to generate a code_verifier and a code_challenge:

  • code verifier: A randomly generated, URL-safe string with at least 43 characters.
  • code_challenge: A derived value from the code verifier, calculated as follows:
    1. Apply SHA-256 hashing to the code verifier.
    2. Encode the result using Base64 URL encoding (without padding).

The final transformation can be represented as:

BASE64URL-ENCODE(SHA256(ASCII(code_verifier)))

๐Ÿš€ OAuth Authentication Process: Step by Step

Here's how your app gets access:

User initiates login
Request Authorization Code
User authenticates
Authorization Code Received
Exchange Authorization Code for Tokens
Refresh Tokens

1๏ธโƒฃ User Logs In

The user clicks Login in your app.

2๏ธโƒฃ Request an Authorization Code

Your app sends a request to the authorization serverโ€™s /auth endpoint with:

  • redirect_uri
  • code_challenge
  • Other required parameters
OAuth scopes

Just request the codeโ€”no need to set extra OAuth scopes!

curl -i -X GET \
  'https://iam.wallapop.com/realms/wallapop-connect/protocol/openid-connect/auth?client_id=string&response_type=code&redirect_uri=http%3A%2F%2Fexample.com&code_challenge=string&code_challenge_method=S256'

3๏ธโƒฃ User Authentication

The professional user is redirected to Wallapopโ€™s login page. Once authenticated, with their mail and password used on Wallapop, they are sent back to your app.

Description of image

4๏ธโƒฃ Authorization Code Received

Your app receives an authorization code via the redirect_uri.

5๏ธโƒฃ Exchange Authorization Code for Tokens

Your app sends a POST request to /token with:

  • Authorization code
  • code_verifier
  • Other required parameters
curl -i -X POST \
  https://iam.wallapop.com/realms/wallapop-connect/protocol/openid-connect/token \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'User-Agent: string' \
  -d grant_type=authorization_code \
  -d code=string \
  -d redirect_uri=http://example.com \
  -d code_verifier=string \
  -d client_id=string \
  -d client_secret=string

๐Ÿ’ก Response:

  • access_token (short-lived, grants access to Wallapop resources)
  • refresh_token (used to get a new access token when expired)

Making API Calls with Your Access Token

Now that you have an access_token, you can start making API requests! Just include it in the Authorization header like this:

curl -v 'https://connect.wallapop.com/{uri}/' \
  -H 'Authorization: Bearer ${access_token}'
Additional headers

Some requests may require extra headers. Check the API catalog for details.


First API Call: Create an Item

For your first API request, create an item while passing the access token in the Bearer authorization header.

Using real values

This is just a demo! Feel free to swap out the example values with your own, using the Request Body Schema tab for field details.

Request

curl -i -X POST \
  https://connect.wallapop.com/items \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "item": {
      "category_leaf_id": "9931",
      "title": "Title example",
      "description": "A renowned line of performance and lifestyle sneakers that offer superior comfort, support, and style both on and off the court.",
      "price": {
        "cash_amount": 75.5,
        "currency": "EUR"
      },
      "attributes": {
        "external_id": "407947058",
        "brand": "Abc Design",
        "size": 34,
        "condition": "new",
        "color": "yellow"
      },
      "hashtags": [
        "awesome",
        "original"
      ],
      "delivery": {
        "allowed_by_user": true,
        "max_weight_kg": 10,
        "free_shipping": false
      }
    },
    "main_image": {
      "url": "http://cdn.portal.com/image129.jpg"
    },
    "stock": {
      "units": 0
    }
  }'

A successful request returns a 201 Created response, including the id of the newly created item in the response body.

๐Ÿ”„ Refreshing Your Access Token

Tokens expire, but you donโ€™t have to make users log in again! Instead, refresh the token:

curl -i -X POST \
  https://iam.wallapop.com/realms/wallapop-connect/protocol/openid-connect/token \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d grant_type=refresh_token \
  -d refresh_token=string \
  -d client_id=string \
  -d client_secret=string
  • Refresh Token Lifetime: 180 days

Please be aware of the access token rate limits ๐Ÿ˜‰.


๐ŸŽฏ Ready to Go?

Thatโ€™s it! You now know how to authenticate users, obtain access tokens, and interact with the Wallapop API securely. If you have any questions, be sure to check our Frequently Asked Questions section.

Now go aheadโ€”connect, build, and innovate! ๐Ÿš€

For a full list of endpoints and options, check out the API catalogโ€”your go-to reference for everything Wallapop API.