Raistlfiren / garmin-csv-plan

A quick n' dirty way of "automating" training plans into Garmin Connect.
https://raistlfiren.github.io/garmin-csv-plan/
36 stars 5 forks source link

GarminConnect.php - an unexpected response code was found: 403 #27

Closed pygoubet closed 1 week ago

pygoubet commented 9 months ago
Message: "An unexpected response code was found: 403"

In GarminConnect.php line 261:

  An unexpected response code was found: 403

This issue is already referenced in php-garmin-connnect project as Anyone getting 403 error from Garmin Connect starting today? #61

Raistlfiren commented 9 months ago

Thanks @pygoubet, it looks like we will need to use a headless browser or some other means of creating/editing/deleting workouts now based on the code https://github.com/petergardfjall/garminexport/pull/105/files#diff-6093a27e9170fd8a464a72b64b04bca3857c7a77fab45b8dece651661fdfb129

I'll have to look into it soon.

cl201831 commented 9 months ago

Cet outil est génial. J'espère que vous arriverez à trouver une solution. Merci.

Silver-Saucepan commented 8 months ago

For info: I get response code 402 (not 403 as reported above) but I'm guessing it's the same underlying issue

faina09 commented 7 months ago

May be I fixed this issue setting on line 285 of GarminConnect.php:

$strResponse = $this->objConnector->post( 'https://connect.garmin.com/modern/workouts',

instead of 'https://connect.garmin.com/modern/proxy/workout-service/workout'.

But now I got the error:

[critical] Error thrown while running command "garmin:workout "multi-events-day.csv" -vvv". Message: "Warning: Attempt to read property "workoutId" on null" [debug] Command "garmin:workout "multi-events-day.csv" -vvv" exited with code "1"

In GarminHelper.php line 69:

[ErrorException] Warning: Attempt to read property "workoutId" on null

Raistlfiren commented 1 month ago

Hi all,

Please test the latest release. I have updated the code base to use the latest authentication method from Garmin. Authentication is a convoluted five-step process with Garmin. It is using Garth's consumer key and secret - https://thegarth.s3.amazonaws.com/oauth_consumer.json

I have not tagged or created a release for this version, yet. I also haven't added anything to handle MFA by Garmin.

Thanks

pygoubet commented 1 month ago

Hi @Raistlfiren Well done! It worked (after a little change). It would be great if the GARMIN_AUTHENTICATION_FILE could be overridden at run time. Or hardcoded to a subfolder within the workdir /usr/src/garmin-csv-plan. As example public const GARMIN_AUTHENTICATION_FILE = 'tmp/garmin_credentials.json';. In my case, /usr/src/garmin-csv-plan is not writable, so the credential file cannot be created.

Raistlfiren commented 1 month ago

Thanks @pygoubet. I added a variable in the .env file called GARMIN_AUTHENTICATION_FILE_PATH where you can specify the path. :)

cl201831 commented 1 month ago

Many THANKS @Raistlfiren for taking the time to resolve this issue. Best regards. It works very well.

faina09 commented 1 month ago

great @Raistlfiren now it works fine, thanks!

pygoubet commented 1 month ago

Thanks @pygoubet. I added a variable in the .env file called GARMIN_AUTHENTICATION_FILE_PATH where you can specify the path. :)

Very convenient, thanks!