andrew-blake / britishgas_myenergy_client

British Gas My Energy Client - download smart meter usage data
MIT License
13 stars 6 forks source link

Json response from BG changed? #1

Closed vzorglub closed 7 years ago

vzorglub commented 8 years ago

Hello after running the script I get:

python download-usage.py INFO:urllib3.connectionpool:Starting new HTTPS connection (1): www.britishgas.co.uk send: 'POST /mobile/iphone/OAMAuthenticate HTTP/1.1\r\nContent-Length: 161\r\nAccept-Language: en-GB;q=1, en;q=0.9, ja;q=0.8, el;q=0.7\r\nProxy-Connection: keep-alive\r\nConnection: keep-alive\r\nAccept: /\r\nUser-Agent: British Gas/2.1.70 (iPod touch; iOS 8.1.2; Scale/2.00)\r\nHost: www.britishgas.co.uk\r\nCookie: SessionPersistence=CLICKSTREAMCLOUD:=visitorId=anonymous|PROFILEDATA:=avatar=/etc/designs/default/images/collab/avatar.png,isLoggedIn=true,isLoggedIn_xss=true,authorizableId=anonymous,authorizableId_xss=anonymous,formattedName=,formattedName_xss=|TAGCLOUD:=|SURFERINFO:=IP=127.0.0.1,keywords=,browser=WebKit,OS=Mac OS X,resolution=320x568|; homepage_beta=false; ecos.dt=1467630190000\r\nContent-Type: application/x-www-form-urlencoded\r\nAccept-Encoding: gzip, deflate\r\n\r\nusername=XXXXXXX%40gmail.com&deviceName=iPod+Touch&password=XXXXXX&clientVersion=6.1.7&responseType=JSON&iOSVersion=8.1.2&channel=itouch&deviceVersion=iPod5.1' reply: 'HTTP/1.1 200 OK\r\n' header: Date: Mon, 04 Jul 2016 11:03:11 GMT header: Server: Apache header: X-Frame-Options: SAMEORIGIN header: Set-Cookie: JSESSIONID=LlpjX6CPvqLRY58nzXydWVFndVkDSfyGpg4k50gfnJkbxvtzd2Rw!-884868058; path=/; HttpOnly header: Set-Cookie: BG_COOKIE_ID=XFuGhV04692018141792615797194541; path=/; secure header: X-Powered-By: Servlet/2.5 JSP/2.1 header: Vary: Accept-Encoding,User-Agent header: Content-Encoding: gzip header: Content-Length: 171 header: Keep-Alive: timeout=2, max=80 header: Connection: Keep-Alive header: Content-Type: application/json DEBUG:urllib3.connectionpool:"POST /mobile/iphone/OAMAuthenticate HTTP/1.1" 200 171 Traceback (most recent call last): File "download-usage.py", line 8, in client = MyEnergyClient(username=USERNAME, password=PASSWORD, proxies=PROXIES, debug=DEBUG, ssl_verify=SSL_VERIFY) File "/opt/openhab/python/britishgas_myenergy_client.py", line 65, in init self._login() File "/opt/openhab/python/britishgas_myenergy_client.py", line 129, in _login self.account_number = self.response['OAMAuthenticate']['Accounts'][0]['AccountNumber'] KeyError: 'Accounts'

If you suspect this is an IPython bug, please report it at: https://github.com/ipython/ipython/issues or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug" to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via: %config Application.verbose_crash=True

I believe that the Json response from BG has changed and therefore the key error

Would you be able to investigate?

Thanks

andrew-blake commented 8 years ago

Yes, I get this error message too. I'll need to look at the latest App, but I'm not sure how soon I'll get chance to do that.

'{"OAMAuthenticate":{"isAuthenticated":"FALSE","isJCI":"false","StatusCode":"-1601","Message":"We have made some changes to our App. Please download the latest version from the store."}}'

potchin commented 7 years ago

Did you ever get this working again? Looks like a great tool

andrew-blake commented 7 years ago

Sorry - no. Not reached the top of the to-do list.

tinoest commented 7 years ago

Where it says clientVersion: 6.1.7 Change it to 6.2.6 and it will work again.

I had to make some changes to work on python 3.4 but I'd guess that's all it needs for python 2.7 ( assume it was written for this )

vzorglub commented 7 years ago

Hi, thanks for that. It worked... sort off. I get the the OAM auth json and the nectar card json but the BG data is as follow:

{ "status": { "httpStatus": 401, "success": false }, "data": { "message": "UnauthorizedError: Invalid Session.", "messages": [ { "message": "Invalid XCSRF Token" } ] } }

And this is the log on terminal:

INFO:urllib3.connectionpool:Starting new HTTPS connection (1): www.britishgas.co.uk send: 'POST /mobile/Nectar/Summary HTTP/1.1\r\nContent-Length: 116\r\nAccept-Language: en-GB;q=1, en;q=0.9, ja;q=0.8, el;q=0.7\r\nProxy-Connection: keep-alive\r\nConnection: keep-alive\r\nAccept: /\r\nUser-Agent: British Gas/2.1.70 (iPod touch; iOS 8.1.2; Scale/2.00)\r\nHost: www.britishgas.co.uk\r\nCookie: ecos.dt=1488225702000; BG_COOKIE_ID=cDoIU463080069621474341652242708; SessionPersistence=CLICKSTREAMCLOUD:=visitorId=anonymous|PROFILEDATA:=avatar=/etc/designs/default/images/collab/avatar.png,isLoggedIn=true,isLoggedIn_xss=true,authorizableId=anonymous,authorizableId_xss=anonymous,formattedName=,formattedName_xss=|TAGCLOUD:=|SURFERINFO:=IP=127.0.0.1,keywords=,browser=WebKit,OS=Mac OS X,resolution=320x568|; homepage_beta=false; JSESSIONID=SQpdY0FBrMY7xbcjF20kH1r7yNGtsS0GZQ4gsNhW1skXNVPpHVMN!-1953424207\r\nContent-Type: application/x-www-form-urlencoded\r\nAccept-Encoding: gzip, deflate\r\n\r\nresponseType=JSON&clientVersion=6.1.7&step=1&ucrn=300020909949&deviceVersion=iPod5.1&channel=itouch&iOSVersion=8.1.2' reply: 'HTTP/1.1 200 OK\r\n' header: Date: Mon, 27 Feb 2017 20:01:43 GMT header: Server: Apache header: X-Frame-Options: SAMEORIGIN header: X-Powered-By: Servlet/2.5 JSP/2.1 header: Vary: Accept-Encoding,User-Agent header: Content-Encoding: gzip header: Content-Length: 213 header: Keep-Alive: timeout=2, max=80 header: Connection: Keep-Alive header: Content-Type: application/json DEBUG:urllib3.connectionpool:"POST /mobile/Nectar/Summary HTTP/1.1" 200 213 Wrote: api-response-mobile-Nectar-Summary.json INFO:urllib3.connectionpool:Starting new HTTPS connection (1): www.britishgas.co.uk send: 'GET /myenergy_prod/api/usage/day/2017-02-26 HTTP/1.1\r\nAccept-Language: en-GB;q=1, en;q=0.9, ja;q=0.8, el;q=0.7\r\nProxy-Connection: keep-alive\r\nConnection: keep-alive\r\nAccept: /\r\nUser-Agent: British Gas/2.1.70 (iPod touch; iOS 8.1.2; Scale/2.00)\r\nHost: www.britishgas.co.uk\r\nCookie: ecos.dt=1488225703000; BG_COOKIE_ID=cDoIU463080069621474341652242708; SessionPersistence=CLICKSTREAMCLOUD:=visitorId=anonymous|PROFILEDATA:=avatar=/etc/designs/default/images/collab/avatar.png,isLoggedIn=true,isLoggedIn_xss=true,authorizableId=anonymous,authorizableId_xss=anonymous,formattedName=,formattedName_xss=|TAGCLOUD:=|SURFERINFO:=IP=127.0.0.1,keywords=,browser=WebKit,OS=Mac OS X,resolution=320x568|; homepage_beta=false; JSESSIONID=SQpdY0FBrMY7xbcjF20kH1r7yNGtsS0GZQ4gsNhW1skXNVPpHVMN!-1953424207\r\nAccept-Encoding: gzip, deflate\r\n\r\n' reply: 'HTTP/1.1 401 Unauthorized\r\n' header: Date: Mon, 27 Feb 2017 20:01:44 GMT header: Server: nginx/1.4.6 (Ubuntu) header: X-Frame-Options: SAMEORIGIN header: Content-Type: application/json; charset=utf-8 header: X-Powered-By: Express header: x-request-received: 1488225704424 header: x-response-sent: 1488225704438 header: Vary: Accept-Encoding,User-Agent header: Content-Encoding: gzip header: Content-Length: 135 header: Keep-Alive: timeout=2, max=80 header: Connection: Keep-Alive DEBUG:urllib3.connectionpool:"GET /myenergy_prod/api/usage/day/2017-02-26 HTTP/1.1" 401 135 Wrote: api-response-api-usage-day-2017-02-26.json

Still getting unauthorised responses for some of the requests Any other changes that you made?

What are your sources for Python 3.4?

Thanks

tinoest commented 7 years ago

You don't appear to have changed all instances of your client version. There were three I changed. I can see one 6.1.7 in your debug log.

I'll create a pull request with my changes in later.

vzorglub commented 7 years ago

Hello, I have change the 3 occurences of Version in the code and I am still getting the issue.

See below:

INFO:urllib3.connectionpool:Starting new HTTPS connection (1): www.britishgas.co.uk send: 'POST /mobile/iphone/OAMAuthenticate HTTP/1.1\r\nContent-Length: 161\r\nAccept-Language: en-GB;q=1, en;q=0.9, ja;q=0.8, el;q=0.7\r\nProxy-Connection: keep-alive\r\nConnection: keep-alive\r\nAccept: /\r\nUser-Agent: British Gas/2.1.70 (iPod touch; iOS 8.1.2; Scale/2.00)\r\nHost: www.britishgas.co.uk\r\nCookie: SessionPersistence=CLICKSTREAMCLOUD:=visitorId=anonymous|PROFILEDATA:=avatar=/etc/designs/default/images/collab/avatar.png,isLoggedIn=true,isLoggedIn_xss=true,authorizableId=anonymous,authorizableId_xss=anonymous,formattedName=,formattedName_xss=|TAGCLOUD:=|SURFERINFO:=IP=127.0.0.1,keywords=,browser=WebKit,OS=Mac OS X,resolution=320x568|; homepage_beta=false; ecos.dt=1488482657000\r\nContent-Type: application/x-www-form-urlencoded\r\nAccept-Encoding: gzip, deflate\r\n\r\nusername=vzorglub%40gmail.com&deviceName=iPod+Touch&password=Spirou01&clientVersion=6.2.6&responseType=JSON&iOSVersion=8.1.2&channel=itouch&deviceVersion=iPod5.1' reply: 'HTTP/1.1 200 OK\r\n' header: Date: Thu, 02 Mar 2017 19:24:18 GMT header: Server: Apache header: X-Frame-Options: SAMEORIGIN header: Set-Cookie: UAA-SSID=efdb1204-420c-4a0b-b68e-090fb241d509; path=/; secure; HttpOnly header: Set-Cookie: BG_COOKIE_ID=JIKeJ961569957533047961844586985; path=/; secure header: Set-Cookie: JSESSIONID=wPcfY4xChsrSTRN1QFBTcTgs5kRdjBMpm1JTRPLQFV4BgQHNKCVH!1273532514; path=/; HttpOnly header: Set-Cookie: BG_COOKIE_ID=RPilT247497023914319926266898420; path=/; secure header: X-Powered-By: Servlet/2.5 JSP/2.1 header: Vary: Accept-Encoding,User-Agent header: Content-Encoding: gzip header: Content-Length: 334 header: Keep-Alive: timeout=2, max=80 header: Connection: Keep-Alive header: Content-Type: application/json DEBUG:urllib3.connectionpool:"POST /mobile/iphone/OAMAuthenticate HTTP/1.1" 200 334 Account: 911001265897 Ucrn: 300020909949 Wrote: api-response-mobile-iphone-OAMAuthenticate.json INFO:urllib3.connectionpool:Starting new HTTPS connection (1): www.britishgas.co.uk send: 'POST /mobile/iphone/ser HTTP/1.1\r\nContent-Length: 106\r\nAccept-Language: en-GB;q=1, en;q=0.9, ja;q=0.8, el;q=0.7\r\nProxy-Connection: keep-alive\r\nConnection: keep-alive\r\nAccept: /\r\nUser-Agent: British Gas/2.1.70 (iPod touch; iOS 8.1.2; Scale/2.00)\r\nHost: www.britishgas.co.uk\r\nCookie: ecos.dt=1488482662000; BG_COOKIE_ID=RPilT247497023914319926266898420; SessionPersistence=CLICKSTREAMCLOUD:=visitorId=anonymous|PROFILEDATA:=avatar=/etc/designs/default/images/collab/avatar.png,isLoggedIn=true,isLoggedIn_xss=true,authorizableId=anonymous,authorizableId_xss=anonymous,formattedName=,formattedName_xss=|TAGCLOUD:=|SURFERINFO:=IP=127.0.0.1,keywords=,browser=WebKit,OS=Mac OS X,resolution=320x568|; homepage_beta=false; JSESSIONID=wPcfY4xChsrSTRN1QFBTcTgs5kRdjBMpm1JTRPLQFV4BgQHNKCVH!1273532514\r\nContent-Type: application/x-www-form-urlencoded\r\nAccept-Encoding: gzip, deflate\r\n\r\naccountNumber=911001265897&accountType=Combined&channel=itouch&clientVersion=6.2.6&deviceVersion=iPod5%2C1' reply: 'HTTP/1.1 302 Found\r\n' header: Date: Thu, 02 Mar 2017 19:24:22 GMT header: Server: Apache header: X-Frame-Options: SAMEORIGIN header: Location: https://www.britishgas.co.uk/content/britishgas/errorpages/errorpage_app.html header: X-Powered-By: Servlet/2.5 JSP/2.1 header: Vary: Accept-Encoding,User-Agent header: Content-Encoding: gzip header: Content-Length: 219 header: Keep-Alive: timeout=2, max=80 header: Connection: Keep-Alive DEBUG:urllib3.connectionpool:"POST /mobile/iphone/ser HTTP/1.1" 302 219 send: 'GET /content/britishgas/errorpages/errorpage_app.html HTTP/1.1\r\nAccept-Language: en-GB;q=1, en;q=0.9, ja;q=0.8, el;q=0.7\r\nProxy-Connection: keep-alive\r\nHost: www.britishgas.co.uk\r\nAccept: /\r\nUser-Agent: British Gas/2.1.70 (iPod touch; iOS 8.1.2; Scale/2.00)\r\nConnection: keep-alive\r\nCookie: ecos.dt=1488482662000; BG_COOKIE_ID=RPilT247497023914319926266898420; SessionPersistence=CLICKSTREAMCLOUD:=visitorId=anonymous|PROFILEDATA:=avatar=/etc/designs/default/images/collab/avatar.png,isLoggedIn=true,isLoggedIn_xss=true,authorizableId=anonymous,authorizableId_xss=anonymous,formattedName=,formattedName_xss=|TAGCLOUD:=|SURFERINFO:=IP=127.0.0.1,keywords=,browser=WebKit,OS=Mac OS X,resolution=320x568|; homepage_beta=false; JSESSIONID=wPcfY4xChsrSTRN1QFBTcTgs5kRdjBMpm1JTRPLQFV4BgQHNKCVH!1273532514\r\nContent-Type: application/x-www-form-urlencoded\r\nAccept-Encoding: gzip, deflate\r\n\r\n' reply: 'HTTP/1.1 200 OK\r\n' header: Date: Thu, 02 Mar 2017 19:24:23 GMT header: Server: Apache header: X-Frame-Options: SAMEORIGIN header: X-Powered-By: Servlet/2.5 JSP/2.1 header: Vary: Accept-Encoding,User-Agent header: Content-Encoding: gzip header: Content-Length: 4601 header: Keep-Alive: timeout=2, max=79 header: Connection: Keep-Alive header: Content-Type: text/html; charset=UTF-8 DEBUG:urllib3.connectionpool:"GET /content/britishgas/errorpages/errorpage_app.html HTTP/1.1" 200 4601 X-CSRF-Token: None INFO:urllib3.connectionpool:Starting new HTTPS connection (1): www.britishgas.co.uk send: 'GET /myenergy_prod/api/user HTTP/1.1\r\nAccept-Language: en-GB;q=1, en;q=0.9, ja;q=0.8, el;q=0.7\r\nProxy-Connection: keep-alive\r\nConnection: keep-alive\r\nAccept: /\r\nUser-Agent: British Gas/2.1.70 (iPod touch; iOS 8.1.2; Scale/2.00)\r\nHost: www.britishgas.co.uk\r\nCookie: ecos.dt=1488482663000; BG_COOKIE_ID=RPilT247497023914319926266898420; SessionPersistence=CLICKSTREAMCLOUD:=visitorId=anonymous|PROFILEDATA:=avatar=/etc/designs/default/images/collab/avatar.png,isLoggedIn=true,isLoggedIn_xss=true,authorizableId=anonymous,authorizableId_xss=anonymous,formattedName=,formattedName_xss=|TAGCLOUD:=|SURFERINFO:=IP=127.0.0.1,keywords=,browser=WebKit,OS=Mac OS X,resolution=320x568|; homepage_beta=false; JSESSIONID=wPcfY4xChsrSTRN1QFBTcTgs5kRdjBMpm1JTRPLQFV4BgQHNKCVH!1273532514\r\nAccept-Encoding: gzip, deflate\r\n\r\n' reply: 'HTTP/1.1 401 Unauthorized\r\n' header: Date: Thu, 02 Mar 2017 19:24:23 GMT header: Server: nginx/1.4.6 (Ubuntu) header: X-Frame-Options: SAMEORIGIN header: Content-Type: application/json; charset=utf-8 header: X-Powered-By: Express header: x-request-received: 1488482663816 header: x-response-sent: 1488482663823 header: Vary: Accept-Encoding,User-Agent header: Content-Encoding: gzip header: Content-Length: 135 header: Keep-Alive: timeout=2, max=80 header: Connection: Keep-Alive DEBUG:urllib3.connectionpool:"GET /myenergy_prod/api/user HTTP/1.1" 401 135 Wrote: api-response-api-user.json INFO:urllib3.connectionpool:Starting new HTTPS connection (1): www.britishgas.co.uk send: 'GET /myenergy_prod/api/direct/user/premise HTTP/1.1\r\nAccept-Language: en-GB;q=1, en;q=0.9, ja;q=0.8, el;q=0.7\r\nProxy-Connection: keep-alive\r\nConnection: keep-alive\r\nAccept: /\r\nUser-Agent: British Gas/2.1.70 (iPod touch; iOS 8.1.2; Scale/2.00)\r\nHost: www.britishgas.co.uk\r\nCookie: ecos.dt=1488482663000; BG_COOKIE_ID=RPilT247497023914319926266898420; SessionPersistence=CLICKSTREAMCLOUD:=visitorId=anonymous|PROFILEDATA:=avatar=/etc/designs/default/images/collab/avatar.png,isLoggedIn=true,isLoggedIn_xss=true,authorizableId=anonymous,authorizableId_xss=anonymous,formattedName=,formattedName_xss=|TAGCLOUD:=|SURFERINFO:=IP=127.0.0.1,keywords=,browser=WebKit,OS=Mac OS X,resolution=320x568|; homepage_beta=false; JSESSIONID=wPcfY4xChsrSTRN1QFBTcTgs5kRdjBMpm1JTRPLQFV4BgQHNKCVH!1273532514\r\nAccept-Encoding: gzip, deflate\r\n\r\n' reply: 'HTTP/1.1 401 Unauthorized\r\n' header: Date: Thu, 02 Mar 2017 19:24:24 GMT header: Server: nginx/1.4.6 (Ubuntu) header: X-Frame-Options: SAMEORIGIN header: Content-Type: application/json header: X-Powered-By: Express header: Vary: Accept-Encoding,User-Agent header: Content-Encoding: gzip header: Content-Length: 110 header: Keep-Alive: timeout=2, max=80 header: Connection: Keep-Alive DEBUG:urllib3.connectionpool:"GET /myenergy_prod/api/direct/user/premise HTTP/1.1" 401 110 Wrote: api-response-api-direct-user-premise.json INFO:urllib3.connectionpool:Starting new HTTPS connection (1): www.britishgas.co.uk send: 'POST /mobile/Nectar/Summary HTTP/1.1\r\nContent-Length: 116\r\nAccept-Language: en-GB;q=1, en;q=0.9, ja;q=0.8, el;q=0.7\r\nProxy-Connection: keep-alive\r\nConnection: keep-alive\r\nAccept: /\r\nUser-Agent: British Gas/2.1.70 (iPod touch; iOS 8.1.2; Scale/2.00)\r\nHost: www.britishgas.co.uk\r\nCookie: ecos.dt=1488482664000; BG_COOKIE_ID=RPilT247497023914319926266898420; SessionPersistence=CLICKSTREAMCLOUD:=visitorId=anonymous|PROFILEDATA:=avatar=/etc/designs/default/images/collab/avatar.png,isLoggedIn=true,isLoggedIn_xss=true,authorizableId=anonymous,authorizableId_xss=anonymous,formattedName=,formattedName_xss=|TAGCLOUD:=|SURFERINFO:=IP=127.0.0.1,keywords=,browser=WebKit,OS=Mac OS X,resolution=320x568|; homepage_beta=false; JSESSIONID=wPcfY4xChsrSTRN1QFBTcTgs5kRdjBMpm1JTRPLQFV4BgQHNKCVH!1273532514\r\nContent-Type: application/x-www-form-urlencoded\r\nAccept-Encoding: gzip, deflate\r\n\r\nresponseType=JSON&clientVersion=6.2.6&step=1&ucrn=300020909949&deviceVersion=iPod5.1&channel=itouch&iOSVersion=8.1.2' reply: 'HTTP/1.1 200 OK\r\n' header: Date: Thu, 02 Mar 2017 19:24:24 GMT header: Server: Apache header: X-Frame-Options: SAMEORIGIN header: X-Powered-By: Servlet/2.5 JSP/2.1 header: Vary: Accept-Encoding,User-Agent header: Content-Encoding: gzip header: Content-Length: 213 header: Keep-Alive: timeout=2, max=80 header: Connection: Keep-Alive header: Content-Type: application/json DEBUG:urllib3.connectionpool:"POST /mobile/Nectar/Summary HTTP/1.1" 200 213 Wrote: api-response-mobile-Nectar-Summary.json INFO:urllib3.connectionpool:Starting new HTTPS connection (1): www.britishgas.co.uk send: 'GET /myenergy_prod/api/usage/day/2017-03-01 HTTP/1.1\r\nAccept-Language: en-GB;q=1, en;q=0.9, ja;q=0.8, el;q=0.7\r\nProxy-Connection: keep-alive\r\nConnection: keep-alive\r\nAccept: /\r\nUser-Agent: British Gas/2.1.70 (iPod touch; iOS 8.1.2; Scale/2.00)\r\nHost: www.britishgas.co.uk\r\nCookie: ecos.dt=1488482665000; BG_COOKIE_ID=RPilT247497023914319926266898420; SessionPersistence=CLICKSTREAMCLOUD:=visitorId=anonymous|PROFILEDATA:=avatar=/etc/designs/default/images/collab/avatar.png,isLoggedIn=true,isLoggedIn_xss=true,authorizableId=anonymous,authorizableId_xss=anonymous,formattedName=,formattedName_xss=|TAGCLOUD:=|SURFERINFO:=IP=127.0.0.1,keywords=,browser=WebKit,OS=Mac OS X,resolution=320x568|; homepage_beta=false; JSESSIONID=wPcfY4xChsrSTRN1QFBTcTgs5kRdjBMpm1JTRPLQFV4BgQHNKCVH!1273532514\r\nAccept-Encoding: gzip, deflate\r\n\r\n' reply: 'HTTP/1.1 401 Unauthorized\r\n' header: Date: Thu, 02 Mar 2017 19:24:26 GMT header: Server: nginx/1.4.6 (Ubuntu) header: X-Frame-Options: SAMEORIGIN header: Content-Type: application/json; charset=utf-8 header: X-Powered-By: Express header: x-request-received: 1488482666147 header: x-response-sent: 1488482666159 header: Vary: Accept-Encoding,User-Agent header: Content-Encoding: gzip header: Content-Length: 135 header: Keep-Alive: timeout=2, max=80 header: Connection: Keep-Alive DEBUG:urllib3.connectionpool:"GET /myenergy_prod/api/usage/day/2017-03-01 HTTP/1.1" 401 135 Wrote: api-response-api-usage-day-2017-03-01.json INFO:urllib3.connectionpool:Starting new HTTPS connection (1): www.britishgas.co.uk send: 'GET /myenergy_prod/api/usage/month/2017-03-01 HTTP/1.1\r\nAccept-Language: en-GB;q=1, en;q=0.9, ja;q=0.8, el;q=0.7\r\nProxy-Connection: keep-alive\r\nConnection: keep-alive\r\nAccept: /\r\nUser-Agent: British Gas/2.1.70 (iPod touch; iOS 8.1.2; Scale/2.00)\r\nHost: www.britishgas.co.uk\r\nCookie: ecos.dt=1488482666000; BG_COOKIE_ID=RPilT247497023914319926266898420; SessionPersistence=CLICKSTREAMCLOUD:=visitorId=anonymous|PROFILEDATA:=avatar=/etc/designs/default/images/collab/avatar.png,isLoggedIn=true,isLoggedIn_xss=true,authorizableId=anonymous,authorizableId_xss=anonymous,formattedName=,formattedName_xss=|TAGCLOUD:=|SURFERINFO:=IP=127.0.0.1,keywords=,browser=WebKit,OS=Mac OS X,resolution=320x568|; homepage_beta=false; JSESSIONID=wPcfY4xChsrSTRN1QFBTcTgs5kRdjBMpm1JTRPLQFV4BgQHNKCVH!1273532514\r\nAccept-Encoding: gzip, deflate\r\n\r\n' reply: 'HTTP/1.1 401 Unauthorized\r\n' header: Date: Thu, 02 Mar 2017 19:24:26 GMT header: Server: nginx/1.4.6 (Ubuntu) header: X-Frame-Options: SAMEORIGIN header: Content-Type: application/json; charset=utf-8 header: X-Powered-By: Express header: x-request-received: 1488482666746 header: x-response-sent: 1488482666752 header: Vary: Accept-Encoding,User-Agent header: Content-Encoding: gzip header: Content-Length: 135 header: Keep-Alive: timeout=2, max=80 header: Connection: Keep-Alive DEBUG:urllib3.connectionpool:"GET /myenergy_prod/api/usage/month/2017-03-01 HTTP/1.1" 401 135 Wrote: api-response-api-usage-month-2017-03-01.json INFO:urllib3.connectionpool:Starting new HTTPS connection (1): www.britishgas.co.uk send: 'GET /myenergy_prod/api/usage/year/2017-01-01 HTTP/1.1\r\nAccept-Language: en-GB;q=1, en;q=0.9, ja;q=0.8, el;q=0.7\r\nProxy-Connection: keep-alive\r\nConnection: keep-alive\r\nAccept: /\r\nUser-Agent: British Gas/2.1.70 (iPod touch; iOS 8.1.2; Scale/2.00)\r\nHost: www.britishgas.co.uk\r\nCookie: ecos.dt=1488482666000; BG_COOKIE_ID=RPilT247497023914319926266898420; SessionPersistence=CLICKSTREAMCLOUD:=visitorId=anonymous|PROFILEDATA:=avatar=/etc/designs/default/images/collab/avatar.png,isLoggedIn=true,isLoggedIn_xss=true,authorizableId=anonymous,authorizableId_xss=anonymous,formattedName=,formattedName_xss=|TAGCLOUD:=|SURFERINFO:=IP=127.0.0.1,keywords=,browser=WebKit,OS=Mac OS X,resolution=320x568|; homepage_beta=false; JSESSIONID=wPcfY4xChsrSTRN1QFBTcTgs5kRdjBMpm1JTRPLQFV4BgQHNKCVH!1273532514\r\nAccept-Encoding: gzip, deflate\r\n\r\n' reply: 'HTTP/1.1 401 Unauthorized\r\n' header: Date: Thu, 02 Mar 2017 19:24:27 GMT header: Server: nginx/1.4.6 (Ubuntu) header: X-Frame-Options: SAMEORIGIN header: Content-Type: application/json; charset=utf-8 header: X-Powered-By: Express header: x-request-received: 1488482667386 header: x-response-sent: 1488482667397 header: Vary: Accept-Encoding,User-Agent header: Content-Encoding: gzip header: Content-Length: 135 header: Keep-Alive: timeout=2, max=80 header: Connection: Keep-Alive DEBUG:urllib3.connectionpool:"GET /myenergy_prod/api/usage/year/2017-01-01 HTTP/1.1" 401 135 Wrote: api-response-api-usage-year-2017-01-01.json

As you can see, I am not getting a valid X-CSRF-Token: "X-CSRF-Token: None" and it follows that I don't get data. I still get account details and nectar data.

Regards

vzorglub commented 7 years ago

Hello, but this issue is not resolved, why did you close it? Thanks

On 4 Mar 2017 13:07, "Andrew Blake" notifications@github.com wrote:

Closed #1 https://github.com/andrew-blake/britishgas_myenergy_client/issues/1.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/andrew-blake/britishgas_myenergy_client/issues/1#event-986455046, or mute the thread https://github.com/notifications/unsubscribe-auth/ASmb4EPYCnbG_FgOefIGKh9NVRjpV2vxks5riWIRgaJpZM4JESjg .

tinoest commented 7 years ago

The latest master version had, unless they've updated the api again. In which case I'd hope it was just a increment by 1 to make it work again.

bachoo786 commented 5 years ago

Hello

How do I use your script? I am a little new to python and was wondering how do I go about using your script?

Thanks.

bachoo786 commented 5 years ago

ok so I run the script and I get nothing as an output.

Is anyone facing the same problem?