{"action":"created","issue":{"url":"https://api.github.com/repos/djchen/oauth2-fitbit/issues/5","repository_url":"https://api.github.com/repos/djchen/oauth2-fitbit","labels_url":"https://api.github.com/repos/djchen/oauth2-fitbit/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/djchen/oauth2-fitbit/issues/5/comments","events_url":"https://api.github.com/repos/djchen/oauth2-fitbit/issues/5/events","html_url":"https://github.com/djchen/oauth2-fitbit/issues/5","id":129846512,"number":5,"title":"Refreshing the Access Token","user":{"login":"ljhardy","id":16847300,"avatar_url":"https://avatars.githubusercontent.com/u/16847300?v=3","gravatar_id":"","url":"https://api.github.com/users/ljhardy","html_url":"https://github.com/ljhardy","followers_url":"https://api.github.com/users/ljhardy/followers","following_url":"https://api.github.com/users/ljhardy/following{/other_user}","gists_url":"https://api.github.com/users/ljhardy/gists{/gist_id}","starred_url":"https://api.github.com/users/ljhardy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljhardy/subscriptions","organizations_url":"https://api.github.com/users/ljhardy/orgs","repos_url":"https://api.github.com/users/ljhardy/repos","events_url":"https://api.github.com/users/ljhardy/events{/privacy}","received_events_url":"https://api.github.com/users/ljhardy/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-01-29T18:33:38Z","updated_at":"2016-08-24T19:08:05Z","closed_at":"2016-01-30T16:20:39Z","body":"This is certainly not a problem with your library, but with my understanding.  I ran the first part of your example and it worked great, I stored the access token and the refresh token to disk.  My use case is such that only the first time authenticating, and storing the tokens, all happen via the web.  All other accesses will happen on a schedule, run from a server, accessing the tokens.\r\n\r\nMy understanding is that Fitbit requires a refreshed token for each access.  I am struggling with your example refresh logic.  I'm able to read the access and the refresh token from disk and I know at this point that the access token is expired and needs to be refreshed.  I don't understand thIs part:\r\n\r\n  $newAccessToken = $provider->getAccessToken('refresh_token', [\r\n        'refresh_token' => $existingAccessToken->getRefreshToken()\r\n\r\nThe $existingAccessToken was just read from disk and doesn't have the getRefreshToken method available to it?  What am I missing here?\r\n\r\nThanks, Len\r\n\r\n\r\n$provider = new djchen\\OAuth2\\Client\\Provider\\Fitbit([\r\n    'clientId'          => '{fitbit-oauth2-client-id}',\r\n    'clientSecret'      => '{fitbit-client-secret}',\r\n    'redirectUri'       => 'https://example.com/callback-url'\r\n]);\r\n\r\n$existingAccessToken = getAccessTokenFromYourDataStore();\r\n\r\nif ($existingAccessToken->hasExpired()) {\r\n    $newAccessToken = $provider->getAccessToken('refresh_token', [\r\n        'refresh_token' => $existingAccessToken->getRefreshToken()\r\n    ]);\r\n\r\n    // Purge old access token and store new access token to your data store.\r\n}"},"comment":{"url":"https://api.github.com/repos/djchen/oauth2-fitbit/issues/comments/242175294","html_url":"https://github.com/djchen/oauth2-fitbit/issues/5#issuecomment-242175294","issue_url":"https://api.github.com/repos/djchen/oauth2-fitbit/issues/5","id":242175294,"user":{"login":"istvanskeri","id":1731822,"avatar_url":"https://avatars.githubusercontent.com/u/1731822?v=3","gravatar_id":"","url":"https://api.github.com/users/istvanskeri","html_url":"https://github.com/istvanskeri","followers_url":"https://api.github.com/users/istvanskeri/followers","following_url":"https://api.github.com/users/istvanskeri/following{/other_user}","gists_url":"https://api.github.com/users/istvanskeri/gists{/gist_id}","starred_url":"https://api.github.com/users/istvanskeri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/istvanskeri/subscriptions","organizations_url":"https://api.github.com/users/istvanskeri/orgs","repos_url":"https://api.github.com/users/istvanskeri/repos","events_url":"https://api.github.com/users/istvanskeri/events{/privacy}","received_events_url":"https://api.github.com/users/istvanskeri/received_events","type":"User","site_admin":false},"created_at":"2016-08-24T19:08:05Z","updated_at":"2016-08-24T19:08:05Z","body":"Are you also storing the expiration time in the database then? "}}
{"actor":{"display_login":"istvanskeri"}}