Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customer is not logged in #12

Open
nebriv opened this issue May 20, 2022 · 0 comments
Open

Customer is not logged in #12

nebriv opened this issue May 20, 2022 · 0 comments

Comments

@nebriv
Copy link

nebriv commented May 20, 2022

Hello,

Trying to give this a shot. I've provided credentials with TOTP. Based on the output screenshots it looks like we're able to login however when making the API request to opower it doesn't appear to pass the credentials through. The final screenshot I get is meter3-2.png resulting with "Error: details: Customer is not logged in." I'll see if I can figure out how pyppeteer is supposed to handle this and see if I can get it working.

        # Access the API using your newly acquired authentication cookies!
        api_page = await browser.newPage()
        api_url = 'https://' + self.data_site + '.opower.com/ei/edge/apis/cws-real-time-ami-v1/cws/' + self.data_site + '/accounts/' + self.account_uuid + '/meters/' + self.meter_number + '/usage'
        await api_page.goto(api_url)
        await api_page.screenshot({'path': 'meter3-2.png'})
Traceback (most recent call last):
  File "\venv\lib\site-packages\coned\meter.py", line 103, in last_read
    raise MeterError(jsonResponse['error']['details'])
coned.meter.MeterError: Customer is not logged in. (76f0e2cc-54a1-4c9b-9e57-38cbe4fbe485)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 15, in <module>
    startTime, endTime, value, unit_of_measurement = event_loop.run_until_complete(meter.last_read())
  File "C:\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "\venv\lib\site-packages\coned\meter.py", line 118, in last_read
    raise MeterError("Error requesting meter data")

EDIT:
Dumping the cookies on the opower.com page in the python request it looks like it does not contain the JSESSIONID cookie (seen in network inspection in chrome). I'm not sure where this session cookie is set, possibly in javascript somewhere?

Editing the request and randomizing the JSESSIONID results in the same not logged in error I am seeing in the screenshot so it is highly likely this is the problematic portion.

EDIT EDIT:
After logging it I think we need to make a request to the dashboard to get a valid session with opower. By adding the following lines I'm able to get usage data, however the script still fails with a Navigation Timeout Exceeded on page.py.

        opower_dash_url = 'https://www.coned.com/en/accounts-billing/dashboard?tab1=billingandusage-1&tab2=sectionEnergyBillingUsage-1&tab3=sectionRealTimeData-3'
        await page.goto(opower_dash_url )
        sleep = 5000
        await page.waitFor(sleep)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant