Skip to content

Commit

Permalink
fix: Etsy OAuth2 Authentication bugs (#880)
Browse files Browse the repository at this point in the history
* fix: Etsy OAuth2 Authentication bugs

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* refactor: removed unnecessary change

* fix equality

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
amitray007 and pre-commit-ci[bot] committed Jan 31, 2024
1 parent f6d81fd commit 4bb29b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion social_core/backends/etsy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ class EtsyOAuth2(BaseOAuth2PKCE):
AUTHORIZATION_URL = "https://www.etsy.com/oauth/connect"
ACCESS_TOKEN_URL = "https://api.etsy.com/v3/public/oauth/token"
REFRESH_TOKEN_URL = "https://api.etsy.com/v3/public/oauth/token"
PKCE_DEFAULT_CODE_CHALLENGE_METHOD = "S256"
ACCESS_TOKEN_METHOD = "POST"
REQUEST_TOKEN_METHOD = "POST"
SCOPE_SEPARATOR = " "
REDIRECT_STATE = False
EXTRA_DATA = [
("refresh_token", "refresh_token"),
("expires_in", "expires_in"),
Expand Down Expand Up @@ -38,5 +40,5 @@ def get_user_details(self, response):
"last_name": response["last_name"],
"email": response["primary_email"],
"image_url_75x75": response["image_url_75x75"],
"username": response["user_id"],
"username": str(response["user_id"]),
}
5 changes: 3 additions & 2 deletions social_core/tests/backends/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,15 @@ def do_login(self):
code_challenge = auth_request.querystring.get("code_challenge")[0]
code_challenge_method = auth_request.querystring.get("code_challenge_method")[0]
self.assertIsNotNone(code_challenge)
self.assertEqual(code_challenge_method, "s256")
self.assertTrue(code_challenge_method in ["s256", "S256"])

auth_complete = [
r for r in requests if self.backend.access_token_url() in r.url
][0]
code_verifier = auth_complete.parsed_body.get("code_verifier")[0]
self.assertEqual(
self.backend.generate_code_challenge(code_verifier, "s256"), code_challenge
self.backend.generate_code_challenge(code_verifier, code_challenge_method),
code_challenge,
)

return user

0 comments on commit 4bb29b1

Please sign in to comment.