I have successfully authenticated the user and storing users token/secret in
database. Now I need to pull the data for that user based on the token/secret
that I have stored in the database. How can I do that?
We used to save Token and Secret in our database but every time the FitBit asks
user their Authentication and then followed by another window "Allow" and
"Deny" to synch data.
Following is the code that we are using in our c# web application :
that means : response.HasProtectedResource = null always
const string ConsumerKey = "xxx";
const string ConsumerSecret = "xxx";
const string RequestTokenUrl = "http://www.fitbit.com/oauth/request_token";
string AuthorizationUrl = "http://www.fitbit.com/oauth/authorize";
const string AccessTokenUrl = "http://api.fitbit.com/oauth/access_token";
const string ApiCallUrl = "http://api.fitbit.com/1/user/-/profile.xml";
OAuthService service = OAuthService.Create(
new EndPoint(RequestTokenUrl, "POST"), // requestTokenEndPoint
new Uri(AuthorizationUrl), // authorizationUri
new EndPoint(AccessTokenUrl, "POST"), // accessTokenEndPoint
true, // useAuthorizationHeader
"http://api.fitbit.com", // realm
"HMAC-SHA1", // signatureMethod
"1.0", // oauthVersion
new OAuthConsumer(ConsumerKey, ConsumerSecret) // consumer
);
OAuthRequest request = OAuthRequest.Create(
new OAuth.Net.Consumer.EndPoint(ApiCallUrl, "GET"),
service,
this.Context.Request.Url,
this.Session.SessionID);
request.VerificationHandler = AspNetOAuthRequest.HandleVerification;
OAuthResponse response = request.GetResource();
if (!response.HasProtectedResource)
{
string authorizationUrl = service.BuildAuthorizationUrl(response.Token).AbsoluteUri;
Response.Redirect(authorizationUrl);
}
GetResource() method always returns HasProtectedResource = false. I need it to
return true. I know I have to pass the token/secret but I need to know where.
I have successfully authenticated the user and storing users token/secret in
database. Now I need to pull the data for that user based on the token/secret
that I have stored in the database. How can I do that?
Original issue reported on code.google.com by greenbri...@gmail.com on 3 Jun 2014 at 7:21
Original issue reported on code.google.com by
greenbri...@gmail.com
on 3 Jun 2014 at 7:21