Error with RequestToken in SampleMVC?
Hello Aaron,
I trying many time, why fall pairing with Fitbit. According to my researching you may transmit by session more things.
Because when you generating in Callback something this
RequestToken token = new RequestToken();
token.Token = Request.Params["oauth_token"];
token.Secret = Session["FitbitRequestTokenSecret"].ToString();
token.Verifier = Request.Params["oauth_verifier"];
and after this action are values token.Token = null token.Secret = "some code from working at Authorize" token.Verifier = null
In my code before your solution I transmit Secret and also Token from Authorize to CallBack.
I think that Secret and Token are necessary for method GetAuthCredentialFromPin, too.
Milan
I'm a little unclear what the problem is as this latest version / solution did fix the auth problems I and others encountered when Fitbit updated their OAuth 1.0a implementation. If you're advocating we put all fields of the RequestToken object in to session I'd be fine updating the SampleMVC app to do something like:
Session["FitbitRequestToken"] = token;
And then to retrieve it we'd do:
RequestToken token = (RequestToken)Session["FitbitRequestToken"];
Does that solve the issue?
--Aaron
Hello Aaron,
That is what I meant. It seems odd that nobody said anything. Am I the only one who is working on this project in ASP .NET MVC?
Milan
No, many people including me are using this library as-is in ASP.NET MVC. You don't need anything except the RequestToken.Secret at the callback stage (after the user has authenticated) because the other 2 pieces are included in the querystring on return. You can pull those like so:
(in callback controller):
RequestToken token = new RequestToken();
token.Token = Request.Params["oauth_token"];
token.Verifier = Request.Params["oauth_verifier"];
token.Secret = RequestTokenSecret; //var from Session or DB.
But, if it makes you happier, put the RequestToken object in Session and maintain it there. It's the same thing.
I do not know.
RequestToken token = new RequestToken (); token.Token Request.Params = ["oauth_token"]; token.Verifier Request.Params = ["oauth_verifier"]; token.Secret = RequestTokenSecret / / var from Session or DB.
Has always generated:
token.Token = null, token.Verifier = null, token.Secret = "key from Fitbit"
I spent two days of my life testing this and a colleague of mine was testing it in his own code and it did not work for him either.Otherwise I would not post here.
Not sure what to tell you. It's there. See "Step D" in the OAuth Flow which specifies that the user is returned back to your app and that the request includes "oauth_token" and "oauth_verifier":
https://wiki.fitbit.com/display/API/OAuth+Authentication+in+the+Fitbit+API#OAuthAuthenticationintheFitbitAPI-TheOAuthFlow
Maybe examine more of the low-level HTTP you're initially getting and see if it's in the url. If you're quickly redirecting the user after that callback then it won't be in there. Also in the dev.fitbit.com settings for that app make sure your key is set to type "web" and not "desktop".
--Aaron
It is your project and you must decide, what you want to do. In my experience, it is necessary to pass it on between controllers like this.
Technically it depends on ASP.NET MVC coders. I only wanted to point it out, which I already did.
That to add I have problem with this in ASP.NET MVC4.
I also want to add, that it does not work your way for me in ASP .NET MVC4
Works fine for me.
I think this is user specific, closing it until we get some testable / repeatable code.