PHP Classes

Fitbit Oauth2

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  How to Implement a PH...  >  All threads  >  Fitbit Oauth2  >  (Un) Subscribe thread alerts  
Subject:Fitbit Oauth2
Summary:Issue using login_with_fitbit2
Messages:22
Author:Tyler
Date:2016-04-21 17:45:56
 
  1 - 10   11 - 20   21 - 22  

  1. Fitbit Oauth2   Reply   Report abuse  
Picture of Tyler Tyler - 2016-04-21 17:45:56
I am having an issue with the $client->access_token in the fitbit2.php file. When I run the PHP, I receive authorization from Fitbit (for use of profile) and then I get redirected. When redirection occurs, I receive the state and the code appended to the URL. For some reason, it is not displaying my profile information. I seem to be going to the ($client->exit) if-statement instead of the third if-statement(if(strlen($client->access_token). I am using the most recent http.php and oauth_client.php. Is there another file that I am missing or what do you think my issue is?

Thank you

  2. Re: Fitbit Oauth2   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-04-21 19:23:29 - In reply to message 1 from Tyler
This may be a sign that your PHP sessions may not be working. Can you please set the debug variable to true and post the PHP error log contents here?

  3. Re: Fitbit Oauth2   Reply   Report abuse  
Picture of Tyler Tyler - 2016-04-21 20:15:00 - In reply to message 2 from Manuel Lemos
I just looked at the oauth_client.php file. Do i need to add the line
<stringvalue>Fitbit2</stringvalue> to the list? I saw that there were others with oauth1 and 2 options and there is only Fitbit in the current version. I will wait until your reply before I send error log.

  4. Re: Fitbit Oauth2   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-04-21 21:22:49 - In reply to message 3 from Tyler
No, that is documentation.

If you use the example login_with_fitbit2.php it should work with OAuth 2.

  5. Re: Fitbit Oauth2   Reply   Report abuse  
Picture of Tyler Tyler - 2016-04-22 14:50:04 - In reply to message 4 from Manuel Lemos
Good morning,

I was able to access the error_log and for some reason everything (profile information) is being printed in the error_log. Is there a way to have the data print to another file, like a text file? Below is the error log regarding the Oauth process.


[22-Apr-2016 16:45:14 Europe/Paris] OAuth client: Checking if OAuth access token was already retrieved from https://api.fitbit.com/oauth2/token

[22-Apr-2016 16:45:14 Europe/Paris] OAuth client: The OAuth access token eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NjEzMzk0MTksInNjb3BlcyI6Indwcm8iLCJzdWIiOiIzNzdCSlkiLCJhdWQiOiIyMjdONzgiLCJpc3MiOiJGaXRiaXQiLCJ0eXAiOiJhY2Nlc3NfdG9rZW4iLCJpYXQiOjE0NjEzMzU4MTl9.Y3SwCK2wqGojCTLodsK_F3ppCd18pzh9sxYC2FP1qJ0 is valid

[22-Apr-2016 16:45:14 Europe/Paris] OAuth client: The OAuth access token expires on 2016-04-22 15:36:59

[22-Apr-2016 16:45:14 Europe/Paris] OAuth client: The OAuth access token is of type Bearer

[22-Apr-2016 16:45:14 Europe/Paris] OAuth client: Accessing the API call at https://api.fitbit.com/1/user/-/profile.json

[22-Apr-2016 16:45:14 Europe/Paris] Connecting to api.fitbit.com

[22-Apr-2016 16:45:14 Europe/Paris] Resolving HTTP server domain "api.fitbit.com"...

[22-Apr-2016 16:45:15 Europe/Paris] Connecting to HTTP server IP 104.16.65.50 port 443...

[22-Apr-2016 16:45:15 Europe/Paris] Connected to api.fitbit.com

[22-Apr-2016 16:45:15 Europe/Paris] C GET /1/user/-/profile.json HTTP/1.1

[22-Apr-2016 16:45:15 Europe/Paris] C Host: api.fitbit.com

[22-Apr-2016 16:45:15 Europe/Paris] C User-Agent: PHP-OAuth-API (http://www.phpclasses.org/oauth-api $Revision: 1.146 $)

[22-Apr-2016 16:45:15 Europe/Paris] C Accept: */*

[22-Apr-2016 16:45:15 Europe/Paris] C Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NjEzMzk0MTksInNjb3BlcyI6Indwcm8iLCJzdWIiOiIzNzdCSlkiLCJhdWQiOiIyMjdONzgiLCJpc3MiOiJGaXRiaXQiLCJ0eXAiOiJhY2Nlc3NfdG9rZW4iLCJpYXQiOjE0NjEzMzU4MTl9.Y3SwCK2wqGojCTLodsK_F3ppCd18pzh9sxYC2FP1qJ0

[22-Apr-2016 16:45:15 Europe/Paris] C Connection: Keep-Alive

[22-Apr-2016 16:45:15 Europe/Paris] C

[22-Apr-2016 16:45:15 Europe/Paris] S HTTP/1.1 200 OK

[22-Apr-2016 16:45:15 Europe/Paris] S Server: cloudflare-nginx

[22-Apr-2016 16:45:15 Europe/Paris] S Date: Fri, 22 Apr 2016 14:44:24 GMT

[22-Apr-2016 16:45:15 Europe/Paris] S Content-Type: application/json;charset=UTF-8

[22-Apr-2016 16:45:15 Europe/Paris] S Transfer-Encoding: chunked

[22-Apr-2016 16:45:15 Europe/Paris] S Connection: keep-alive

[22-Apr-2016 16:45:15 Europe/Paris] S Cache-control: no-cache, private

[22-Apr-2016 16:45:15 Europe/Paris] S Fitbit-Rate-Limit-Limit: 150

[22-Apr-2016 16:45:15 Europe/Paris] S Fitbit-Rate-Limit-Remaining: 148

[22-Apr-2016 16:45:15 Europe/Paris] S Fitbit-Rate-Limit-Reset: 936

[22-Apr-2016 16:45:15 Europe/Paris] S Content-Language: en

[22-Apr-2016 16:45:15 Europe/Paris] S Vary: Accept-Encoding

[22-Apr-2016 16:45:15 Europe/Paris] S X-Frame-Options: SAMEORIGIN

[22-Apr-2016 16:45:15 Europe/Paris] S CF-RAY: 2979da84bdc02591-ORD

Thank you for all of your help!
Tyler

  6. Re: Fitbit Oauth2   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-04-22 23:51:29 - In reply to message 5 from Tyler
Currently the class only sends messages to the error log. I can add an option to send the error log to another file.

As for the API calls they seem to be working. They return status 200. What is the problem you were having?

  7. Re: Fitbit Oauth2   Reply   Report abuse  
Picture of Tyler Tyler - 2016-04-23 00:08:02 - In reply to message 6 from Manuel Lemos
If you would be able to add the option to write to another file or create a file and write to it that would be awesome. I am currently a college student and I was going through the college's PHP/Apache so I do not have access to the PHP Error Logs. I had to set up a WAMP localhost so that is how I was able to access the php error log. It would be easier for me if I could output the data into a text file rather than the error log.

I would like to thank you so much for all the work you have done on your code as well as for all your help in this process. You have been extremely helpful!
Thanks, Tyler

  8. Re: Fitbit Oauth2   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-04-23 02:17:30 - In reply to message 7 from Tyler
OK, so does the API call work for you now?

  9. Re: Fitbit Oauth2   Reply   Report abuse  
Picture of Tyler Tyler - 2016-04-23 06:49:57 - In reply to message 8 from Manuel Lemos
Yes the API works now. It appears to have been on our side that the error occured.

  10. Re: Fitbit Oauth2   Reply   Report abuse  
Picture of Tyler Tyler - 2016-04-24 15:33:25 - In reply to message 9 from Tyler
Hi Manuel,
I was just wondering if you were going to create something that would allow me to output my fitbit data to another file besides outputting to the PHP error log? It would be really helpful and I know it would be utilized by future users. Thanks, Tyler

 
  1 - 10   11 - 20   21 - 22