13

I am trying to query information from my private team and tried the following:

  1. Registered an app

    Name = stackoverflow.com/c/{team}
    OAuth domain = stackoverflow.com
    Application web site = https://stackoverflow.com/c/{team} 
    

Got client id, client secret and a key.

  1. Authentication trial (explicit)

I have put into the browser the following URL:

https://stackoverflow.com/oauth/?client_id={id}&scope=no_expiry&redirect_uri=https://stackoverflow.com

Got the code.

Switched to Postman and got the access_token based on client_id, client_secret, redirect_uri and the code.

Now, I am trying to use a simple API method to check if I can access anything for my Team:

https://api.stackexchange.com/2.2/info?site={???}&access_token={token}&key={key}

This works for Stack Overflow. Tried with stackoverflow/c/{team}, but it does not know about it (which kind of makes sense since I expected to generate some sort of key inside my private team space).

  1. I have replaced the first step's URL with:

    https://stackoverflow.com/oauth/?client_id={client_id}&scope=access_team|https://stackoverflow/c/{team}&redirect_uri=https://stackoverflow.com
    

Got a rather long code and switched to Postman:

GET: https://api.stackexchange.com/2.2/info?site=stackoverflow&team=https://stackoverflow.com/c/{team}&key={key}
Headers: X-API-Access-Token = {the_code_from_previous_step}

If I do not specify the key, I receive the following error:

{
"error_id": 405,
"error_message": "key is required when access_token is passed.",
"error_name": "key_required"
}

If I specify the key I got when defining the app:

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

What is the correct way to retrieve information from my team?

5
  • Do you think that Meta Stack Overflow is the best place to ask this about the SE API? Apr 15, 2019 at 17:56
  • 1
    @double-beep - this is more about the stack-overflow-for-teams than the API itself (they have the tag here). Also, this question deals with SE API and was migrated here, so I guess this is an appropriate place. Do you think I could increase my chances of getting an answer elsewhere? Apr 15, 2019 at 18:15
  • You might not need https:// protocol prefix on the teams query parameter, e.g. ?team=stackoverflow.com/c/pickles. Apr 15, 2019 at 18:17
  • Just FYI there is stackapps.com where you can ask about the SE API. The question you mentioned was migrated from meta Stack Exchange, but not from StackApps. I think it is worth trying it. Delete this question, repost it in StackApps and hope for help. However, note that now you got help, so it is no longer worth trying it :) Apr 15, 2019 at 18:18
  • Somewhat related: stackapps.com/questions/8202/… Apr 15, 2019 at 18:48

1 Answer 1

16

It looks like the scope query parameter you passed when obtaining your access token didn't have the access_team|stackoverflow.com/c/your-team-url, as detailed in the Teams-specific docs.

I think you'd want scope=no_expiry,access_team|stackoverflow.com/c/your-team-url.

3
  • Yes, you are right. I have just realized that and I am trying to check all the flow. Apr 15, 2019 at 18:35
  • I was able to reproduce your initial error and changing the scope does allow you into the API; however, I got a "this method is not supported when querying a team" response on the /info route. Changing to /posts showed me all is working! Apr 15, 2019 at 18:44
  • 11
    Now everything is clear. However, I think the documentation should have been more straightforward for SO for Teams (i.e. one page including the flows for it, not having to look for multiple times in two places). Thanks for the support. Apr 15, 2019 at 18:48

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