Skip to content

Commit

Permalink
Merge pull request #34 from praw-dev/revoke_token
Browse files Browse the repository at this point in the history
api/v1/revoke_token HTTP status code change
  • Loading branch information
LilSpazJoekp authored Jun 15, 2021
2 parents cfac173 + bfd38a5 commit eb89024
Show file tree
Hide file tree
Showing 11 changed files with 726 additions and 701 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Unreleased

- Support 202 "Accepted" HTTP responses.

**Fixed**

- The expected HTTP response status code for a request made with the proper credentials
to api/v1/revoke_token has been changed from 204 to 200.

2.1.0 (2021/06/15)
------------------

Expand Down
2 changes: 1 addition & 1 deletion asyncprawcore/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def revoke_token(self, token, token_type=None):
if token_type is not None:
data["token_type_hint"] = token_type
url = self._requestor.reddit_url + const.REVOKE_TOKEN_PATH
await self._post(url, success_status=codes["no_content"], **data)
await self._post(url, **data)


class TrustedAuthenticator(BaseAuthenticator):
Expand Down
342 changes: 172 additions & 170 deletions tests/cassettes/Authorizer_revoke__access_token_with_refresh_set.json
Original file line number Diff line number Diff line change
@@ -1,173 +1,175 @@
{
"version": 1,
"interactions": [
{
"request": {
"method": "POST",
"uri": "https://www.reddit.com/api/v1/access_token",
"body": [
[
"grant_type",
"refresh_token"
],
[
"refresh_token",
"fake_refresh_token"
]
],
"headers": {
"User-Agent": [
"asyncprawcore:test (by /u/bboe) asyncprawcore/1.4.0"
],
"Connection": [
"close"
],
"AUTHORIZATION": [
"Basic <placeholder_auth>"
]
}
},
"response": {
"status": {
"code": 200,
"message": "OK"
},
"headers": {
"Connection": "close",
"Content-Length": "123",
"Content-Type": "application/json; charset=UTF-8",
"x-frame-options": "SAMEORIGIN",
"x-content-type-options": "nosniff",
"x-xss-protection": "1; mode=block",
"cache-control": "max-age=0, must-revalidate",
"X-Moose": "majestic",
"Accept-Ranges": "bytes",
"Date": "Tue, 09 Jun 2020 19:42:04 GMT",
"Via": "1.1 varnish",
"X-Served-By": "cache-ams21041-AMS",
"X-Cache": "MISS",
"X-Cache-Hits": "0",
"X-Timer": "S1591731724.229239,VS0,VE149",
"Set-Cookie": "edgebucket=0tANW8Hs3dLcJMhGvb; Domain=reddit.com; Max-Age=63071999; Path=/; secure",
"Strict-Transport-Security": "max-age=15552000; includeSubDomains; preload",
"Server": "snooserv"
},
"body": {
"string": "{\"access_token\": \"fake_access_Token\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"submit\"}"
},
"url": "https://www.reddit.com/api/v1/access_token"
}
"interactions": [
{
"request": {
"body": [
[
"grant_type",
"refresh_token"
],
[
"refresh_token",
"<REFRESH_TOKEN>"
]
],
"headers": {
"AUTHORIZATION": [
"Basic <BASIC_AUTH>"
],
"Connection": [
"close"
],
"User-Agent": [
"asyncprawcore:test (by /u/Lil_SpazJoekp) asyncprawcore/2.1.1.dev0"
]
},
{
"request": {
"method": "POST",
"uri": "https://www.reddit.com/api/v1/revoke_token",
"body": [
[
"token",
"fake_refresh_token"
],
[
"token_type_hint",
"access_token"
]
],
"headers": {
"User-Agent": [
"asyncprawcore:test (by /u/bboe) asyncprawcore/1.4.0"
],
"Connection": [
"close"
],
"AUTHORIZATION": [
"Basic <placeholder_auth>"
]
}
},
"response": {
"status": {
"code": 204,
"message": "No Content"
},
"headers": {
"Connection": "close",
"Content-Type": "application/json; charset=UTF-8",
"x-frame-options": "SAMEORIGIN",
"x-content-type-options": "nosniff",
"x-xss-protection": "1; mode=block",
"cache-control": "max-age=0, must-revalidate",
"X-Moose": "majestic",
"Accept-Ranges": "bytes",
"Date": "Tue, 09 Jun 2020 19:42:04 GMT",
"Via": "1.1 varnish",
"X-Served-By": "cache-ams21036-AMS",
"X-Cache": "MISS",
"X-Cache-Hits": "0",
"X-Timer": "S1591731724.449686,VS0,VE138",
"Strict-Transport-Security": "max-age=15552000; includeSubDomains; preload",
"Server": "snooserv"
},
"body": {
"string": ""
},
"url": "https://www.reddit.com/api/v1/revoke_token"
}
"method": "POST",
"uri": "https://www.reddit.com/api/v1/access_token"
},
"response": {
"body": {
"string": "{\"access_token\": \"<ACCESS_TOKEN>\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"refresh_token\": \"<REFRESH_TOKEN>\", \"scope\": \"*\"}"
},
{
"request": {
"method": "POST",
"uri": "https://www.reddit.com/api/v1/access_token",
"body": [
[
"grant_type",
"refresh_token"
],
[
"refresh_token",
"fake_refresh_token"
]
],
"headers": {
"User-Agent": [
"asyncprawcore:test (by /u/bboe) asyncprawcore/1.4.0"
],
"Connection": [
"close"
],
"AUTHORIZATION": [
"Basic <placeholder_auth>"
]
}
},
"response": {
"status": {
"code": 200,
"message": "OK"
},
"headers": {
"Connection": "close",
"Content-Length": "123",
"Content-Type": "application/json; charset=UTF-8",
"x-frame-options": "SAMEORIGIN",
"x-content-type-options": "nosniff",
"x-xss-protection": "1; mode=block",
"cache-control": "max-age=0, must-revalidate",
"X-Moose": "majestic",
"Accept-Ranges": "bytes",
"Date": "Tue, 09 Jun 2020 19:42:04 GMT",
"Via": "1.1 varnish",
"X-Served-By": "cache-ams21020-AMS",
"X-Cache": "MISS",
"X-Cache-Hits": "0",
"X-Timer": "S1591731725.782633,VS0,VE144",
"Strict-Transport-Security": "max-age=15552000; includeSubDomains; preload",
"Server": "snooserv"
},
"body": {
"string": "{\"access_token\": \"fake_access_Token\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"scope\": \"submit\"}"
},
"url": "https://www.reddit.com/api/v1/access_token"
}
}
]
}
"headers": {
"Accept-Ranges": "bytes",
"Cache-Control": "max-age=0, must-revalidate",
"Connection": "close",
"Content-Length": "185",
"Content-Type": "application/json; charset=UTF-8",
"Date": "Tue, 15 Jun 2021 04:25:30 GMT",
"Server": "snooserv",
"Set-Cookie": "edgebucket=ANcTGyd6MsX0czw0kK; Domain=reddit.com; Max-Age=63071999; Path=/; secure",
"Strict-Transport-Security": "max-age=15552000; includeSubDomains; preload",
"Via": "1.1 varnish",
"X-Clacks-Overhead": "GNU Terry Pratchett",
"X-Moose": "majestic",
"x-content-type-options": "nosniff",
"x-frame-options": "SAMEORIGIN",
"x-ratelimit-remaining": "190",
"x-ratelimit-reset": "270",
"x-ratelimit-used": "110",
"x-xss-protection": "1; mode=block"
},
"status": {
"code": 200,
"message": "OK"
},
"url": "https://www.reddit.com/api/v1/access_token"
}
},
{
"request": {
"body": [
[
"token",
"dummy token"
],
[
"token_type_hint",
"access_token"
]
],
"headers": {
"AUTHORIZATION": [
"Basic <BASIC_AUTH>"
],
"Connection": [
"close"
],
"User-Agent": [
"asyncprawcore:test (by /u/Lil_SpazJoekp) asyncprawcore/2.1.1.dev0"
]
},
"method": "POST",
"uri": "https://www.reddit.com/api/v1/revoke_token"
},
"response": {
"body": {
"string": ""
},
"headers": {
"Accept-Ranges": "bytes",
"Cache-Control": "max-age=0, must-revalidate",
"Connection": "close",
"Content-Length": "0",
"Content-Type": "application/json; charset=UTF-8",
"Date": "Tue, 15 Jun 2021 04:25:30 GMT",
"Server": "snooserv",
"Strict-Transport-Security": "max-age=15552000; includeSubDomains; preload",
"Via": "1.1 varnish",
"X-Clacks-Overhead": "GNU Terry Pratchett",
"X-Moose": "majestic",
"x-content-type-options": "nosniff",
"x-frame-options": "SAMEORIGIN",
"x-ratelimit-remaining": "188",
"x-ratelimit-reset": "270",
"x-ratelimit-used": "112",
"x-xss-protection": "1; mode=block"
},
"status": {
"code": 200,
"message": "OK"
},
"url": "https://www.reddit.com/api/v1/revoke_token"
}
},
{
"request": {
"body": [
[
"grant_type",
"refresh_token"
],
[
"refresh_token",
"<REFRESH_TOKEN>"
]
],
"headers": {
"AUTHORIZATION": [
"Basic <BASIC_AUTH>"
],
"Connection": [
"close"
],
"User-Agent": [
"asyncprawcore:test (by /u/Lil_SpazJoekp) asyncprawcore/2.1.1.dev0"
]
},
"method": "POST",
"uri": "https://www.reddit.com/api/v1/access_token"
},
"response": {
"body": {
"string": "{\"access_token\": \"<ACCESS_TOKEN>\", \"token_type\": \"bearer\", \"expires_in\": 3600, \"refresh_token\": \"<REFRESH_TOKEN>\", \"scope\": \"*\"}"
},
"headers": {
"Accept-Ranges": "bytes",
"Cache-Control": "max-age=0, must-revalidate",
"Connection": "close",
"Content-Length": "185",
"Content-Type": "application/json; charset=UTF-8",
"Date": "Tue, 15 Jun 2021 04:25:30 GMT",
"Server": "snooserv",
"Strict-Transport-Security": "max-age=15552000; includeSubDomains; preload",
"Via": "1.1 varnish",
"X-Clacks-Overhead": "GNU Terry Pratchett",
"X-Moose": "majestic",
"x-content-type-options": "nosniff",
"x-frame-options": "SAMEORIGIN",
"x-ratelimit-remaining": "187",
"x-ratelimit-reset": "270",
"x-ratelimit-used": "113",
"x-xss-protection": "1; mode=block"
},
"status": {
"code": 200,
"message": "OK"
},
"url": "https://www.reddit.com/api/v1/access_token"
}
}
],
"recorded_at": "2021-06-14T23:25:30",
"version": 1
}
Loading

0 comments on commit eb89024

Please sign in to comment.