SSO Logout via Master API Key isn't working

    discourseId = json.loads(urlopen('http://example.com/users/by-external/' + str(g.user_id) + '.json').read().decode('utf-8'))['user']['id']
    # This doesn't work and I have no idea why
    urlopen("http://example.com/admin/users/" + str(discourseId) + "/log_out?api_key=2345139133012345678909de3a3a4fc3ed01abcdef347b983667b0b1f00efb25&api_username=system")

Not my actual API key.

I’ve verified that the user_id passed to discourseId is correct, and I’m able to run the log_out endpoint with no error, it just doesn’t work! I’ve also tried using the actual user in place of system, to no avail.

Am I missing something?

It works if it’s a POST request. Try passing the api_key and api_username as data.

5 Likes

That worked. Thanks a bunch.

2 Likes