p2g_console v4.3.0 - GarminAuthenticationError: failed to authenticate with Garmin. Auth appeared successful, but returned OAuth1 token is null. #706
Replies: 7 comments 5 replies
-
ooooo, just looking at the code, it looks messy with the CSRF, and the service ticket, and the OAuth1 token and the OAuth2 token. My goodness. Garmin published an API that has not been designed for easy consumption. |
Beta Was this translation helpful? Give feedback.
-
Looking at the code, it looks like it gets a service ticket, and then with THAT, tries to sign-in to request ... an OAuth1 request token? I tried reproducing this in Powershell and got the same response: 200 OK, with an empty array as content. That looks unhelpful to an app that wants to parse out an oauth_token and oauth_token_secret from the response. I always seem to get 200 OK with an empty JSON array as a response, whether I have a valid OAuth1 signature in the Authorization header, or even if I send complete junk. I am not sure where to go with this now. Sure looks like Garmin is not responding with a correct response here. Maybe there's nothing wrong with p2g at all, and the problem is all on the Garmin side. Is anyone else having similar problems?
|
Beta Was this translation helpful? Give feedback.
-
oh thanks for that. regarding persistence - what you shared is important information for me if I run p2g_console in a container which has a readonly filesystem. I had mounted two directories for my p2g_console: one for configuration data (readonly) and one for output (for the .fit files , logs, etc). I did not know about the use of A-OK on the passwords. Re: Peloton getting grumpy about frequent logins - I had that experience with Peloton forcing me to change my password. I had previously set the p2g_console to run every 5 minutes and that got me on the naughty list. Since I moved to every 15 minutes, and only during my own daylight hours, my Peloton account has not gotten flagged like that. I just tried writing a Powershell script to replicate what Garth does for signin. It did not work. I can get the CSRF token, apply the cookies, use the proper user agent... but in response to the POST to /signin, I just see an HTML form, with the message, "An unexpected error has occurred." Then I tried running Garth directly, and got the oauth1 and oauth2 tokens successfully,. I don't know what I missed in my own script. Anyway now I have tokens. I will look to see if I can modify p2g_console to use a specific read/write data directory. If I can, then ... I can populate that datastore with my own oauth1 and oauth2 tokens. Do you have an example of what that database file would look like? I guess it's json, but ... I don't have one at hand. All I have is the dummy datastore which looks like this:
|
Beta Was this translation helpful? Give feedback.
-
After further review, I can simply add another r/w storage bucket for the "data" directory; that will be no problem. There will be 3 buckets, 3 mounted directories. One each for config, data, output. I am trying to figure out what needs to go into GarminDbDb.json . End goal is to stuff in the oauth{1,2} tokens obtained via Garth, into that store, so that p2g_console can use cached values. I don't know why it cannot login using the normal path, like Garth does, and I'm trying to work around that. The login process for Garmin remains mysterious. I figure if I can get a successful run of any version of the app, it will create a GarminDbDb.json and I can use that as an example. But I cannot get any version of the app to run successfully at this point. Right now when I run the p2g_console app locally on my windows machine, it behaves the same way as the containerized version that runs in Google Cloud Run: they both succeed in connecting to Peloton, and fail to login to Garmin. When I try to run ClientUI.exe from my own build (v4.3.0) it doesn't do anything. Doesn't start. I downloaded the latest stable release v4.3.1, and double-clicking that in the file explorer i get the warning "Are you sure you want to run this .exe?" I confirm, and ... again, nothing happens. I get a windows spinny wheel for a few seconds, then nothing. No error message. Also tried docker version. Same result - it cannot login to Garmin, so it does not store anything in GarminDbDb.json . |
Beta Was this translation helpful? Give feedback.
-
Thanks for that. I appreciate the back-and-forth, the feedback and assistance. I know you have a day job. The token data obtained by Garth looks like this: oauth1 token
And oauth2 token
So, what does GarminDbDb store? Only the token value? I would think it would need more than that. I haven't looked at the code. In any case I was able to successfully do the Garmin Auth dance from within powershell. I don't know what's different between my powershell script and the GarminAuthenticationService + ApiClient. Investigating. |
Beta Was this translation helpful? Give feedback.
-
hmmmm I'm not sure exactly what the problem was. I changed a couple things and p2g_console can now login to Garmin.
And it works now. See #708 for the changes I made. It is now working
I don't know if you can merge #708 ; I know you have been working on a dotnet 9 version. But the OAuthV1 helper class ought to work just fine. I didn't test the MFA path. |
Beta Was this translation helpful? Give feedback.
-
BTW yesterday I received a notification in my inbox from Garmin that I needed to reset my password. But I also saw in the news that Garmin Connect experienced an outage this morning. Not sure if related or coincidental. It's possible that setting p2g_console to login every 15 or 30 minutes is triggering something on the Garmin side. I would think that caching the OAuth tokens would eliminate that problem , because it eliminates the "Sign in" part. I need to look more closely at this when I get back to my desk. |
Beta Was this translation helpful? Give feedback.
-
I am seeing this error in the logs for the containerized p2g_console app.
Full context here:
I know something about OAuth 1 and 2, and token exchange, etc. But I can't really see what's going on from these logs. I can't even see what was posted to the token exchange endpoint. But it appears the response is an empty array.
I recently updated the garmin password in the config file. Pretty sure that's correct.
Any ideas on what could cause this?
I do not have MFA Setup on this Garmin account.
Can you tell me how I can try the token exchange from here? That might help in diagnosis. I'll try looking in the code, but... no guarantees I'll be able to figure it out.
Beta Was this translation helpful? Give feedback.
All reactions