{
"cod": 401,
"message": "Invalid API key. Please see https://openweathermap.org/faq#error401 for more info."
}
- Go to: https://openweathermap.org/api
- Click "Sign Up"
- Fill out the form
- VERIFY YOUR EMAIL (check inbox, click verification link)
- Login to your account
- Go to "API keys" section
- Click "Generate" or "Create new key"
- Copy the new API key (32 characters long)
- Open
lib/services/weather_service.dart - Find line 9:
static const String _apiKey = 'YOUR_API_KEY_HERE';
- Replace with your new key:
static const String _apiKey = 'your_new_api_key_here';
- Wait 10 minutes for API key activation
- Save the file
- Restart the app:
flutter run - Test the weather feature
- β Key might be from a different account
- β Account email not verified
- β Key was disabled or expired
- β Key format was incorrect
- β 32 characters long
- β Mix of letters and numbers
- β
Example:
a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
- 1,000 API calls per day
- 60 calls per minute
- Perfect for development!
- No 401 error
- Real weather data appears
- Temperature and conditions shown
- No error messages