4

I am attempting to create an application utilizing the API to query data from our private Stack Overflow Teams site.

I've read through the documentation at https://api.stackexchange.com/docs/teams and https://api.stackexchange.com/docs/authentication, but to no avail.

My problem is simply that my requests to the API are denied with the following error:

{"error_id":403,"error_message":"`key` is not valid for passed `access_token`, token not found.","error_name":"access_denied"}

In order to keep our site anonymous, I will simply refer to it as "foosite" in the following text.

What I have done, in order:

  • Used the explicit OAuth API, server side, to generate an access_token using scope=access_team%7cstackoverflow.com%f2c%f2foosite,no_expiry.
  • Passed this access_token using the X-API-Access-Token header for my GET request to https://api.stackexchange.com/2.2/questions/unanswered/?team_url=stackoverflow.com%2fc%2ffoosite&site=stackoverflow&key=u9eRD30bklGv9t9gzDRSAQ((

What I have tried without luck:

  • URL-encoding the key parameter
  • Using applicationKey instead of key, but that seems to be part of the older API
  • Generating new access_token in case the other one would've been invalidated for whatever reason
  • Passing access_token as a query parameter same as for non-team sites, despite the documentation saying that it's not supported
  • Revoking access to the app and then granting it again

From what I can see, I do nothing wrong. Any ideas?

1 Answer 1

2

In this URL: https://api.stackexchange.com/2.2/questions/unanswered/?team_url=stackoverflow.com%2fc%2ffoosite&site=stackoverflow&key=u9eRD30bklGv9t9gzDRSAQ(( you're passing a team_url parameter. That's not the right name, it should be team instead. You are passing the correct value.

4
  • Wow thank you. To think I had missed such an obvious detail. It works like a charm, thank you once again! :)
    – Znurre
    Commented Jan 19, 2019 at 12:49
  • 1
    You're welcome. If it's any consolation, both the resident moderator and I had some troubles getting it to work as well. We both missed the fact that stackoverflow.com/c/ needs to be part of the team parameter.
    – Glorfindel
    Commented Jan 19, 2019 at 12:51
  • Maybe a more helpful error message would not be too much to ask for? Passing an invalid parameter should, in my opinion, yield another error message.
    – Znurre
    Commented Jan 19, 2019 at 12:52
  • The problem is that without the team parameter, the API tries to parse it as a 'regular' API request. Many APIs ignore parameters unknown to them for forward/backward compatibility reasons.
    – Glorfindel
    Commented Jan 19, 2019 at 12:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .