garmin-csv-plan icon indicating copy to clipboard operation
garmin-csv-plan copied to clipboard

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

Open pygoubet opened this issue 1 year ago • 10 comments

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

pygoubet avatar Oct 06 '23 17:10 pygoubet

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.

Raistlfiren avatar Oct 06 '23 19:10 Raistlfiren

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

cl201831 avatar Oct 07 '23 14:10 cl201831

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

Silver-Saucepan avatar Nov 16 '23 17:11 Silver-Saucepan

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

faina09 avatar Dec 20 '23 14:12 faina09

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

Raistlfiren avatar Jun 19 '24 01:06 Raistlfiren

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.

pygoubet avatar Jun 19 '24 12:06 pygoubet

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

Raistlfiren avatar Jun 19 '24 23:06 Raistlfiren

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

cl201831 avatar Jun 20 '24 19:06 cl201831

great @Raistlfiren now it works fine, thanks!

faina09 avatar Jun 21 '24 09:06 faina09

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

Very convenient, thanks!

pygoubet avatar Jun 21 '24 09:06 pygoubet