Configuration Guide
This guide covers everything you need to configure TecMeli with your Mercado Libre API credentials and customize the build for your needs.API Credentials Overview
TecMeli requires three OAuth 2.0 credentials from Mercado Libre to authenticate API requests:| Credential | Purpose | Where It’s Used |
|---|---|---|
| CLIENT_ID | Identifies your application | Token refresh requests |
| CLIENT_SECRET | Authenticates your application | Token refresh requests |
| REFRESH_TOKEN | Long-lived token for obtaining access tokens | Automatic token renewal |
Getting Mercado Libre API Credentials
Create a Mercado Libre Account
If you don’t already have one, create an account at mercadolibre.com
Register Your Application
Go to the Mercado Libre Developer Portal
- Navigate to My Applications
- Click Create Application
- Fill in the application details:
- Name: TecMeli (or your preferred name)
- Short Name: tecmeli
- Description: Android client for Mercado Libre
- Redirect URI:
http://localhost(for testing)
Obtain Client Credentials
After creating your application, you’ll receive:
- Client ID (App ID)
- Client Secret (Secret Key)
Generate Refresh Token
The refresh token requires OAuth 2.0 authorization flow:
-
Construct the authorization URL:
- Visit this URL in a browser and authorize your application
- You’ll be redirected to your redirect URI with an authorization code
-
Exchange the code for tokens using a POST request:
-
Save the
refresh_tokenfrom the response
Creating local.properties
Thelocal.properties file stores your API credentials locally and is never committed to version control.
Location
Create the file in the project root directory:Configuration Format
Createlocal.properties with the following content:
local.properties
Example with Real Values
local.properties
How Credentials Are Used
TecMeli reads credentials fromlocal.properties and injects them into BuildConfig at compile time.
Build Configuration
Fromapp/build.gradle.kts:
app/build.gradle.kts
Runtime Access
The credentials are accessed viaBuildConfig in the NetworkModule:
core/di/NetworkModule.kt
ApiConfig Data Class
The credentials are encapsulated in a data class:core/network/ApiConfig.kt
Token Refresh Flow
TecMeli automatically refreshes access tokens when they expire using the refresh token you configured.How It Works
Initial Request
Every API request includes the current access token via
AuthInterceptor:core/network/AuthInterceptor.kt
Handle 401 Unauthorized
When the token expires, the API returns 401.
TokenAuthenticator intercepts this:core/network/TokenAuthenticator.kt
Refresh Token Request
The
TokenRepository uses your configured credentials to request a new access token:This automatic token refresh ensures users never experience authentication interruptions during normal app usage.
Build Variants
TecMeli uses standard Android build variants:app/build.gradle.kts
Debug Build (Default)
Terminal
- Debuggable: Yes
- Minification: Disabled
- Logging: Full HTTP logging enabled
- Use case: Development and testing
Release Build
Terminal
- Debuggable: No
- Minification: Disabled (can be enabled)
- Logging: Should be reduced in production
- Use case: Production deployment
Verification
After configuring your credentials, verify the setup:1. Clean and Rebuild
Terminal
BuildConfig is regenerated with your credentials.
2. Check BuildConfig
After building, verify the generatedBuildConfig.java:
BuildConfig.java
3. Run the Application
Launch the app on an emulator or device:Terminal
4. Test API Connectivity
In the app:- Enter a search term (e.g., “laptop”)
- Tap the search button
- Verify products are loaded successfully
Troubleshooting
Error: CLIENT_ID not found
Error: CLIENT_ID not found
Symptom: Build error or empty BuildConfig fieldsSolution:
- Verify
local.propertiesexists in the project root - Check property names match exactly:
MELI_CLIENT_ID,MELI_CLIENT_SECRET,MELI_REFRESH_TOKEN - Restart Android Studio and sync Gradle
- Run
./gradlew clean build
Error: 401 Unauthorized
Error: 401 Unauthorized
Error: Network request failed
Error: Network request failed
Symptom: Network errors or timeoutsSolution:
- Check your internet connection
- Verify the base URL in
NetworkModule.kt: - Check OkHttp logs in Logcat for detailed error messages
Empty credentials in BuildConfig
Empty credentials in BuildConfig
Symptom: BuildConfig fields are empty stringsSolution:
The Gradle configuration uses If credentials are empty:
findProperty() which returns null if not found:- Ensure
local.propertiesis in the correct location (project root) - Verify property names are correct
- Restart Android Studio
- Invalidate caches: File → Invalidate Caches / Restart
Security Best Practices
Never Commit Credentials
Always keep credentials in
local.properties, never in version controlUse Environment-Specific Configs
Consider separate credentials for development, staging, and production
Rotate Tokens Regularly
Refresh tokens can be regenerated in the Developer Portal
Enable ProGuard
Obfuscate credentials in release builds using ProGuard/R8
Additional Configuration Options
Network Logging
HTTP logging is configured inNetworkModule.kt:
core/di/NetworkModule.kt
Custom Base URL
To use a different Mercado Libre region or test environment:core/di/NetworkModule.kt
Next Steps
Your TecMeli installation is now complete and configured! Here’s what you can do next:Explore the Architecture
Deep dive into Clean Architecture implementation
Run Tests
Learn about the testing strategy and run the test suite
UI Components
Explore Jetpack Compose UI components
API Reference
Browse the codebase API documentation