Peloton Excercise workout data retreival

I'm attempting to pull data from my Peloton subscription workout data on a daily basis and place in a local DB or Cloud Spreadsheet but those can come later. There are unsupported APIs that are used by a small number of clients. This one being the most recent and working.
paultiplady/peloton-scraper

My current challenge is developing the automated OAUTH PKCE login. I don't have the knowledge interpret the above code and sufficiently wire up in node-red.

Chat Geppetto (GPT) has provided multiple flows but none work.

Would much appreciate pointers to flow that accomplish this effort or redirects to some more relevant samples.

Thank you in advance

Node-Red v4.1.2

[Adim edit, fixed url issue]

the peleton scraper uses the pyloton library, using this class.

logging in seems fairly easy.

i asked another AI to translate it into a node red flow:

I can help you translate this Peloton API login to a Node-RED flow. Here's how to do it:

Node-RED Flow Configuration

You'll need two nodes:

1. HTTP Request Node

Configure it as follows:

  • Method: POST
  • URL: https://api.onepeloton.com/auth/login
  • Return: a parsed JSON object
  • Headers: Add these headers:
    Content-Type: application/json
    User-Agent: pyloton // this can anything apperently.
    

2. Function Node (Before HTTP Request)

This prepares the payload:

// Set credentials
msg.payload = {
    username_or_email: "your_username",
    password: "your_password"
};

// Set headers
msg.headers = {
    "Content-Type": "application/json",
    "User-Agent": "pyloton"
};

return msg;

3. Function Node (After HTTP Request)

This handles the response:

// Check for login error
if (msg.payload.status === 401) {
    node.error(msg.payload.message || "Login Failed");
    return null;
}

// Store user_id for later use
flow.set("peloton_user_id", msg.payload.user_id);
msg.user_id = msg.payload.user_id;

return msg;

Complete Flow Structure

[Inject] → [Function: Prepare Login] → [HTTP Request: POST Login] → [Function: Handle Response] → [Debug]

Note: Store credentials securely using Node-RED environment variables or the credentials system rather than hardcoding them in the function node.

Hello, I really appreciate you taking some time to look at this. Both you and I fell into the GPT rabbit hole where it did not sufficiently know that challenge and proposed answer that followed the most reasonable path.

Unfortunately it is missing the complexity of OAUTH PKCE which is in the following Client File.

There is a good discussion on how this client was updated to use OAUTH PKCE here.

Alas, this is where I am currently stuck.