Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NXDRIVE-2901: Authorization Error for OAuth #4616

Merged
merged 9 commits into from
Apr 3, 2024
1 change: 1 addition & 0 deletions docs/changes/5.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Release date: `2024-xx-xx`
## Core

- [NXDRIVE-2882](https://jira.nuxeo.com/browse/NXDRIVE-2882): fix_db should create dump.sql in same dir as db
- [NXDRIVE-2901](https://jira.nuxeo.com/browse/NXDRIVE-2901): Authorization Error for OAuth
- [NXDRIVE-2](https://jira.nuxeo.com/browse/NXDRIVE-2):

### Direct Edit
Expand Down
6 changes: 4 additions & 2 deletions nxdrive/auth/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
super().__init__(*args, **kwargs)

self._dao = dao
subclient_kwargs = kwargs.get("subclient_kwargs")
gitofanindya marked this conversation as resolved.
Show resolved Hide resolved
subclient_kwargs = {} if subclient_kwargs is None else subclient_kwargs
gitofanindya marked this conversation as resolved.
Show resolved Hide resolved
subclient_kwargs["verify"] = get_verify()

Check warning on line 24 in nxdrive/auth/oauth2.py

View check run for this annotation

Codecov / codecov/patch

nxdrive/auth/oauth2.py#L22-L24

Added lines #L22 - L24 were not covered by tests
self.auth = OAuth2(
self.url,
client_id=Options.oauth2_client_id,
Expand All @@ -28,7 +31,7 @@
redirect_uri=Options.oauth2_redirect_uri,
token_endpoint=Options.oauth2_token_endpoint,
token=self.token,
subclient_kwargs=kwargs.get("subclient_kwargs"),
subclient_kwargs=subclient_kwargs,
)

def connect_url(self) -> str:
Expand All @@ -49,7 +52,6 @@
code_verifier=kwargs["code_verifier"],
code=kwargs["code"],
state=kwargs["state"],
verify=get_verify(),
)

self.token = token
Expand Down
9 changes: 9 additions & 0 deletions tests/functional/test_oauth2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from nxdrive.auth import OAuthentication


def test_oauthentication(manager_factory, nuxeo_url):
gitofanindya marked this conversation as resolved.
Show resolved Hide resolved
manager, engine = manager_factory()
remote = engine.remote
dao = remote.dao
oauth = OAuthentication(nuxeo_url, dao=dao, device_id=None)
assert oauth