stoufa06 / php-garmin-connect-api

PHP library to connect and use garmin wellness api
MIT License
8 stars 11 forks source link

How to create Authorization header after garmin user authorization for getActivitySummary , backfillActivitySummary etc #6

Closed ajithv11 closed 3 years ago

ajithv11 commented 3 years ago

I have successfully connected with garmin and getActivitySummary using $tokenCredentials as given in the README $tokenCredentials = $server->getTokenCredentials($temporaryCredentials, $_GET['oauth_token'], $_GET['oauth_verifier']); This is possible only while connecting

But is there any way to getActivitySummary later by using connected userId , userIdentifier and Secret ?

stoufa06 commented 3 years ago

@ajithv11 You need to store $tokenCredentials and userId in your database and retrieve it anytime to request your activity summary

ajithv11 commented 3 years ago

@stoufa06 Since $tokenCredentials is an object is it ok to store it as serialize string and later retrieve object through unserialize? The details I got is in the format as given below(values are random)

After Authorizing GET params is given below Array ( [oauth_token] => 4e3xxx8b-8126-47f1-b4b7-3xx97108e4bd [oauth_verifier] => Hs1rEos2B1 )

$tokenCredentials League\OAuth1\Client\Credentials\TokenCredentials Object ( [identifier:protected] => abxxxxac-5132-3a9f-xxa0-f4f6exxx3bfc [secret:protected] => 4RPbxxxZxDlc10ixxxbu3BW4RGfxxxutBs5 )

How I can use this to retrieve activities later , Could you please update the code, Since it is not available in the README

stoufa06 commented 3 years ago

@ajithv11 yes

ajithv11 commented 3 years ago

@stoufa06 Could you please share a working code.. When I serialize the variable $tokenCredentials = League\OAuth1\Client\Credentials\TokenCredentials Object ( [identifier:protected] => ab3xxxac-51xx2-3a9f-9xxx-f4f6e6aa3bfc [secret:protected] => 4RxxxxxZxDlc10iGBoxxxxW4RGfBA5utBs5 )

When I tried to underialize the above object, It gives error Notice: unserialize(): Error at offset 79 of 181 bytes

Any healp would be much appreciated as I am trying this for more than 1 week

Serialize data in DB : O:49:"League\OAuth1\Client\Credentials\TokenCredentials":2:{s:13:"identifier";s:36:"xxxxxxxxx-6xx1-4xxe-96a0-e4fxxxxxae3bc";s:9:"secret";s:35:"xRPbxxxxxxlc00iGAobu4bxxxGfBDxxxBS6";}'

Thanks in Advance :)

stoufa06 commented 3 years ago

@ajithv11 I have added example folder in the new release.