### Make Authenticated API Requests Source: https://context7.com/allegro/allegro-api/llms.txt Shows how to perform a GET request to retrieve user profile information. Requires a valid Bearer token in the Authorization header. ```bash curl -X GET "https://api.allegro.pl/me" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "Accept: application/vnd.allegro.public.v1+json" ``` -------------------------------- ### GET /me Source: https://context7.com/allegro/allegro-api/llms.txt Retrieves information about the currently authenticated user. ```APIDOC ## GET /me ### Description Returns the profile details of the user associated with the provided access token. ### Method GET ### Endpoint https://api.allegro.pl/me ### Parameters #### Headers - **Authorization** (string) - Required - Bearer - **Accept** (string) - Required - application/vnd.allegro.public.v1+json ### Response #### Success Response (200) - **id** (string) - User unique identifier - **login** (string) - User login name - **email** (string) - User email address #### Response Example { "id": "12345678", "login": "your_username", "email": "john.doe@example.com" } ``` -------------------------------- ### Handle API Errors Source: https://context7.com/allegro/allegro-api/llms.txt Illustrates an example of an unauthorized request resulting in a 401 error. Developers should implement logic to parse these error responses. ```bash curl -X GET "https://api.allegro.pl/me" \ -H "Authorization: Bearer INVALID_TOKEN" \ -H "Accept: application/vnd.allegro.public.v1+json" ``` -------------------------------- ### Access Sandbox Environment Source: https://context7.com/allegro/allegro-api/llms.txt Demonstrates how to target the sandbox API endpoint for testing purposes. This environment mirrors production but uses test data. ```bash curl -X GET "https://api.allegro.pl.allegrosandbox.pl/me" \ -H "Authorization: Bearer YOUR_SANDBOX_ACCESS_TOKEN" \ -H "Accept: application/vnd.allegro.public.v1+json" ``` -------------------------------- ### Configure API Request Headers Source: https://context7.com/allegro/allegro-api/llms.txt Sets the required headers for versioning and content negotiation when interacting with the Allegro REST API. ```bash curl -X GET "https://api.allegro.pl/sale/offers" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "Accept: application/vnd.allegro.public.v1+json" \ -H "Content-Type: application/vnd.allegro.public.v1+json" ``` -------------------------------- ### Authenticate with OAuth 2.0 Source: https://context7.com/allegro/allegro-api/llms.txt Demonstrates the process of exchanging an authorization code for an access token. This is a required step for all applications to gain authorized access to user data. ```bash curl -X POST "https://allegro.pl/auth/oauth/token" \ -H "Authorization: Basic $(echo -n 'YOUR_CLIENT_ID:YOUR_CLIENT_SECRET' | base64)" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=authorization_code&code=AUTHORIZATION_CODE&redirect_uri=YOUR_REDIRECT_URI" ``` -------------------------------- ### POST /auth/oauth/token Source: https://context7.com/allegro/allegro-api/llms.txt Exchanges an authorization code or refresh token for a valid OAuth 2.0 access token. ```APIDOC ## POST /auth/oauth/token ### Description Exchanges authorization credentials for an access token or refreshes an existing token. ### Method POST ### Endpoint https://allegro.pl/auth/oauth/token ### Parameters #### Request Body - **grant_type** (string) - Required - Must be 'authorization_code' or 'refresh_token' - **code** (string) - Optional - The authorization code received from the redirect URI - **refresh_token** (string) - Optional - The refresh token used to obtain a new access token - **redirect_uri** (string) - Required - The URI used during the initial authorization request ### Request Example { "grant_type": "authorization_code", "code": "AUTHORIZATION_CODE", "redirect_uri": "YOUR_REDIRECT_URI" } ### Response #### Success Response (200) - **access_token** (string) - The bearer token for API requests - **token_type** (string) - Type of token - **refresh_token** (string) - Token used to refresh access - **expires_in** (integer) - Seconds until expiration #### Response Example { "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6...", "token_type": "bearer", "expires_in": 43199 } ``` -------------------------------- ### Refresh Access Tokens Source: https://context7.com/allegro/allegro-api/llms.txt Uses a refresh token to obtain a new access token once the current one expires, ensuring continuous API access without re-authenticating the user. ```bash curl -X POST "https://allegro.pl/auth/oauth/token" \ -H "Authorization: Basic $(echo -n 'YOUR_CLIENT_ID:YOUR_CLIENT_SECRET' | base64)" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=refresh_token&refresh_token=YOUR_REFRESH_TOKEN" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.