My Weather Indicator won't activate World Weather Online

Bug #1595533 reported by Mitch Claborn
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
my-weather-indicator
New
Undecided
Unassigned

Bug Description

Ubuntu 16.04

my-weather-indicator:
  Installed: 0.8.1-0extras16.04.1

When attempting to activate the Word Weather Online service, there is no response in the UI.
The log shows this error:

Error accessing url: 403

Revision history for this message
Doktoil Makresh (doctor) wrote :

Hi,

When trying to use World Weather Online service, looks like my-weather-indicator first tries to request timezone identification :
****** Requesting timezone identificacion
==== **** ====
Error accessing url: 403
==== **** ====

After a quick look into share/my-weather-indicator/geocodeapi.py, I found the following :
def get_timezoneId(lat, lon):
    print('****** Requesting timezone identificacion')
    try:
        json_response = read_json_from_url(
            'http://api.geonames.org/timezoneJSON?lat=\
            %s&lng=%s&username=atareao' % (lat, lon))
        if json_response and 'timezoneId' in json_response.keys():
            return json_response['timezoneId']
    except Exception as e:
        print('Error requesting timezone identification: %s' % (str(e)))
    return 'Europe/London'

I went manually visit http://api.geonames.org and it does request authentication.
According to geocodeapi.py, the username should be atareao, but I can't find the password. Is it expected ?
I think the main problem comes from here, because 403 returned is not handled

Revision history for this message
Doktoil Makresh (doctor) wrote :

Please forget my previous comment, after other tests, I'm able to retrieve info from api.geonames.org using the URL provided in get_timezoneId and passing values for latitude and longitude.

So, the next step is to understand what is reporting 403 error

Revision history for this message
Doktoil Makresh (doctor) wrote :

So, new info, when I try to use URL inside share/my-weather-indicator/worldweatheronlineapi.py, I got the following :

curl -vv "http://api.worldweatheronline.com/free/v1/weather.ashx?q=100,100&format=json&num_of_days=5&key=$MY_KEY$"
* Trying 31.193.9.233...
* Connected to api.worldweatheronline.com (31.193.9.233) port 80 (#0)
> GET /free/v1/weather.ashx?q=100,100&format=json&num_of_days=5&key=$MY_KEY$ HTTP/1.1
> Host: api.worldweatheronline.com
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 403 API key does not have access to the resource.
< Cache-Control: public, max-age=120
< Content-Type: application/json; charset=utf-8
< Expires: Thu, 27 Oct 2016 08:43:18 GMT
< X-Powered-By: ASP.NET
< access-control-allow-origin: *
< access-control-allow-headers: content-type
< Date: Thu, 27 Oct 2016 08:41:18 GMT
< Content-Length: 85
< X-node: zfdl_api_02
< Age: 0
< X-Cache: MISS
< Via: WebCelerate
< X-Webcelerate: WebCelerate - www.ukfast.co.uk/web-acceleration.html
< Connection: keep-alive
<
* Connection #0 to host api.worldweatheronline.com left intact
{ "data": { "error": [ {"msg": "API key does not have access to the resource." } ] }}

Looks like the key used for demo is not allowed to access this resource (free)
When using a demo key to access premium resource, it works :
curl -v "http://api.worldweatheronline.com/premium/v1/weather.ashx?q=100,100&format=json&num_of_days=5&key=$MY_KEY$"
* Trying 31.193.9.233...
* Connected to api.worldweatheronline.com (31.193.9.233) port 80 (#0)
> GET /premium/v1/weather.ashx?q=100,100&format=json&num_of_days=5&key=$MY_KEY$ HTTP/1.1
> Host: api.worldweatheronline.com
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Cache-Control: public, max-age=120
< Content-Type: application/json; charset=utf-8
< Expires: Thu, 27 Oct 2016 08:45:44 GMT
< X-WWO-Qpd-Left: 480
< X-Powered-By: ASP.NET
< access-control-allow-origin: *
< access-control-allow-headers: content-type
< Date: Thu, 27 Oct 2016 08:43:44 GMT
< X-node: zfdl_api_01
< Vary: Accept-Encoding
< Age: 0
< X-Cache: MISS
< Via: WebCelerate
< X-Webcelerate: WebCelerate - www.ukfast.co.uk/web-acceleration.html
< Accept-Ranges: bytes
< Content-Length: 99
< Connection: keep-alive
<
* Connection #0 to host api.worldweatheronline.com left intact
{"data":{"request":[{"type":"LatLon","query":"Lat 100.00 and Lon 100.00"}],"ClimateAverages":null}}

So I attached my patch that only works with premium/demo keys.

Revision history for this message
Doktoil Makresh (doctor) wrote :

By the way, how to get an API key to use free resource ?

Revision history for this message
Zsolt Palotai (zsolt-7) wrote :

Workaround:

If you have the premium key:

1 - edit the config file ( ~/.config/my-weather-indicator/my-weather-indicator.conf )
    "weather-service": "worldweatheronline"
    "wwo-key": "$YOUR_KEY_HERE$"

2 - edit the WWO API Address - /opt/extras.ubuntu.com/my-weather-indicator/share/my-weather-indicator/worldweatheronlineapi.py

    change the API's url to:
URL = 'http://api.worldweatheronline.com/premium/v1/weather.ashx?q=%s,%s\
&format=json&num_of_days=5&key=%s' # (latitude,longitude)

Now, it works.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.