Getting access token each time - Am I missing something?


I'm using an API implementation I took from here: http://developer.yahoo.com/forum/Fantasy-Sports-API/Authenticating-with-NET-using-DotNetOpenAuth/1279209867000-4eee22f1-25fd-3589-9115-1a835add3212

And this code to create an access token:

OAuthWrapper wrapper = new OAuthWrapper(key, secret);
string url = wrapper.BeginAuth();
string validator_token = "";
string accessToken = wrapper.CompleteAuth(validator_token);

Up until now I'm stopping the application run after I get the URL, then manually browsing the URL and manually entering the validator_token. Since I'm the only one using the information from the API and I'm only getting public information, I would like to have a permanent access token for the API. Is it possible? Or am I missing something?


1 Reply
  • Your like 90% of the way there already. I'm assuming your in a web app, so just redirect to the URL you get and then Yahoo seems back the values in the querystring which you already know about since you pulling those out and using those to continue.

    If your not in a web app it is a little more difficult. After you get your values from Yahoo you basically need to serialize your oauth object and reuse it. Except when you reuse a serialized oauth object you need to renew your access token instead of requesting a new one. I'm not sure what library oauthwrapper is from and each library will handle this differently.

    I would recommend starting out with a web app if you haven't already. Its much easier to keep it all in one simple flow. Once you have that figured out you can transfer that knowledge to a system that serializes oauth objects and renews tokens.


Recent Posts

in Fantasy Sports API