1

Getting League key from yahoo login credentials

Hello,

I understand how to query information about a league once I have the league key. I also understand that I can get the league key by going to the webpage for my league and looking at the url, and using that in combination with the applicable game code.

However, I don't want a user to have to do that 2nd step for me. After they authorize access using their yahoo id, I want to be able to get the league keys for the leagues they are a member of with some kind of query. How would I do that?

I tried using the games collection and I also tried a query like this:
CODE
http://fantasysports.yahooapis.com/fantasy/v2/user/{user_id}/teams


These queries have been returning "forbidden access" errors, even when I just make them using the YQL console to eliminate errors in my app as a possible problem. Maybe I am just unclear what the user_id actually is?

Thanks for any help!

by
4 Replies
  • There we go. Did a little more digging and ended up figuring it out myself.

    In case anyone else is trying to do what I was and having issues, you want to use a query like this:

    CODE
    http://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=242/leagues


    That query will return information on all NFL fantasy leagues that the currently logged in player belongs to.
    0
  • I am having problems doing this type of requests.

    This one gives me 403 Forbidden access


    This one works


    Did the API change in the meantime?
    0
  • Your league query worked completely fine for me, although it didn't return any leagues since I don't play fantasy baseball. Not sure what could be wrong.
    0
  • QUOTE (David Queirós @ Mar 21 2011, 03:49 AM) <{POST_SNAPBACK}>
    I am having problems doing this type of requests.

    This one gives me 403 Forbidden access


    This one works


    Did the API change in the meantime?

    Good job figuring out the right query, Mark -- we deprecated the user/<user_id> method of access since we don't really want to encourage passing around Yahoo! IDs directly, so the users;use_login=1 is definitely the preferred pattern.

    David, I'm not exactly sure what would be going on with your query -- like Mark, I'm not having any issues hitting that one. The only things I can think of is that the users;use_login=1 query does include a semicolon -- is that possibly throwing off the request that you're putting together? I know I've seen some OAuth libraries get confused and think they ought to be splitting that off as a URL parameter. Are you getting back any extra error messaging as the response along with the 403 error?

    If you're still having trouble, post back here and I'll try to investigate further.
    0

Recent Posts

in Fantasy Sports API