- Home /
Fitbit CallbackURL
Hey everyone,
I'm trying to get a mobile(droid and hopefully iOS if all goes well) game started that centres around getting data from a user's fitbit and then uses it for in game stats.
I'm running into a pretty big problem where I can get Unity to open a browser window to prompt the user for confirmation. When you hit Allow it correctly produces the OAuth authorization token I would need to grab to be able to get the users data.
Problem is that I have no idea how to get that url from the browser so I can strip the token and authorization token from it. No matter what I try, no matter what library I have tried I can't get it to work.
So I'm trying to find someone that has successfully done OAuth or might be able to give me help figuring out how to get it working with FitBit (since maybe it' just not working correctly with Unity?)
The URL I've got that works for the launching via Application.OpenURL is https://www.fitbit.com/oauth2/authorize?response_type=code&client_id=229PH8&redirect_uri=http%3A%2F%2FfitRPGcallback≻ope=activity%20profile%20sleep%20social
I'm not sure if it's just the callback url that isn't right (it's set as the same in the API) or if it is in fact just missing a way to capture it from Unity itself...
Answer by TEvashkevich · Jan 03, 2016 at 08:59 AM
I forgot to come back and answer this as I was able to get it working eventually.
http://technicalartistry.blogspot.ca/2015/07/oauth2-unity-and-month-of-cursing.html
There is a write up here about the basics of getting it to work and some of the specifics.
EDIT: Did another blogpost about Fitbit, OAuth2 and Unity for Android. This came because Fitbit no longer allows the use of Webviews to do Authentication for security reasons (which is what I was using in the above blogpost) http://technicalartistry.blogspot.ca/2016/01/fitbit-unity-oauth-2-and-native.html This explains how to do it with the use of an Android plugin which is quite easy to make AND free (because you do it yourself :) )
Answer by HabitMonster · Jul 09, 2015 at 04:17 PM
I was able to get FitBit to work with OAuth 1.0, though I'm sure the 2.0 implementation is easier. There were two main tricks: one is to use a more robust HTTP library, as I found the WWW implementation shipped with Unity does not allow for the required POST payload. The second is to use an in-app Web library such as UniWebView, which allows you to pick off the callback URL with the auth token. Good luck. Feel free to message me privately and I'll be happy to share code with you.
Check my answer if you want to know how to do it (code is included :) )