GithubHelp home page GithubHelp logo

Comments (10)

insuusvenerati avatar insuusvenerati commented on July 1, 2024

Actually, after playing around with it, the current issue is getting a 403 forbidden on monthlyData

from southern-company-api.

apearson avatar apearson commented on July 1, 2024

Just tested and monthlyData still works.

Are you getting the connected event? Any error events?

from southern-company-api.

insuusvenerati avatar insuusvenerati commented on July 1, 2024

This is the message I get:

Connected...
Fetch Monthly Error FetchError: invalid json response body at https://customerservice2api.southerncompany.com/api/MyPowerUsage/MonthlyGraph/redacted reason: Unexpected end of JSON input
    at /mnt/misc/Code/gulf-power/.yarn/cache/node-fetch-npm-2.6.6-056db6b778-ee8290626b.zip/node_modules/node-fetch/lib/index.js:273:32
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 0) {
  type: 'invalid-json'
}
Fetch Daily Error FetchError: invalid json response body at https://customerservice2api.southerncompany.com/api/MyPowerUsage/DailyGraph reason: Unexpected end of JSON input
    at /mnt/misc/Code/gulf-power/.yarn/cache/node-fetch-npm-2.6.6-056db6b778-ee8290626b.zip/node_modules/node-fetch/lib/index.js:273:32
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 0) {
  type: 'invalid-json'
}

Using this from the docs.

SouthernCompany.on("connected", () => {
  console.info("Connected...");

  async function fetchMonthly() {
    /* Getting Monthly Data */
    const monthlyData = await SouthernCompany.getMonthlyData();

    /* Printing Monthly Data */
    console.info("Monthly Data", JSON.stringify(monthlyData));
  }

  fetchMonthly().catch((error) => console.log("Fetch Monthly Error", error));

  async function fetchDaily() {
    /* Getting Daily Data */
    const startDate = new Date(2020, 2, 1);
    const endDate = new Date();
    const dailyData = await SouthernCompany.getDailyData(startDate, endDate);

    /* Printing daily data */
    console.info("Daily Data", JSON.stringify(dailyData));
  }

  fetchDaily().catch((error) => console.log("Fetch Daily Error", error));
});

/* Listening for any errors */
SouthernCompany.on("error", console.error);

from southern-company-api.

insuusvenerati avatar insuusvenerati commented on July 1, 2024

This is where it fails:

    /* Waiting for all requests */
    const responses = await Promise.all(requests);

    /* Converting all responses to json */
    const resData: MonthlyDataResponse[] = await Promise.all(
      responses.map((response) => response.json()),
    );

In resData, responses ends up as an array containing the response:

{
  "url": "https://customerservice2api.southerncompany.com/api/MyPowerUsage/MonthlyGraph/redacted",
  "status": 403,
  "statusText": "Forbidden",
  "headers": {},
  "counter": 0
}

from southern-company-api.

apearson avatar apearson commented on July 1, 2024

Interesting, do you have the monthly graphs on the southern company website?

from southern-company-api.

insuusvenerati avatar insuusvenerati commented on July 1, 2024

That's another weird thing but I figured it was a separate issue. I use gulfpower which I can login to fine. However, when I go to login on https://webauth.southernco.com/account/login, it just says Login Succeeded then hangs on Logging in forever.

from southern-company-api.

insuusvenerati avatar insuusvenerati commented on July 1, 2024

Well, I think gulfpower is not part of southern company. At least not anymore. Assuming based on the options on https://customerservice2.southerncompany.com/Landing

from southern-company-api.

apearson avatar apearson commented on July 1, 2024

Yup, that's the issue! Gulf Power was sold to another company and is now using a different backend. Unfortunately this library doesn't support that different backend.

from southern-company-api.

insuusvenerati avatar insuusvenerati commented on July 1, 2024

No worries. Thanks for taking a look

from southern-company-api.

apearson avatar apearson commented on July 1, 2024

Anytime! Good luck!

from southern-company-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.