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

feat: Login flow v2 #255

Merged
merged 9 commits into from
May 22, 2024
Merged

feat: Login flow v2 #255

merged 9 commits into from
May 22, 2024

Conversation

blvdek
Copy link
Contributor

@blvdek blvdek commented May 21, 2024

Changes proposed in this pull request:

  • Implement Login flow v2 for standard Nextcloud clients.
  • Allow user to initialize standard Nextcloud clients without providing credentials so that the user can log in using Login flow v2.

@blvdek blvdek changed the title Feat/loginflow v2 feat: Login flow v2 May 21, 2024
@blvdek blvdek marked this pull request as draft May 21, 2024 07:38
@bigcat88
Copy link
Contributor

To make docs pass you can add:

.. autoclass:: NcSession
    :members:

at the end of Session.rst

And create LoginFlowV2.rst file with such content(and include it in index.rst):

.. py:currentmodule:: nc_py_api.loginflow_v2

LoginFlow V2
============

Two base classes for working with Nextcloud. The first for working as a client, the second as an application.

All required functionality is incorporated in them, they contains all other classes required to work with the Nextcloud.

.. autoclass:: _LoginFlowV2API
    :inherited-members:
    :members:

.. autoclass:: Credentials
    :inherited-members:
    :members:

.. autoclass:: LoginFlow
    :inherited-members:
    :members:

@bigcat88
Copy link
Contributor

and for tests(test_init_poll, test_init_poll_async) as this stuff is not for AppAPI:

nc_any should be nc_client and anc_any should be anc_client

def test_init_poll(nc_client):
    lf = nc_client.loginflow_v2.init()
    ...

this help to not trigger these tests for NextcloudApp class.

@blvdek blvdek marked this pull request as ready for review May 22, 2024 06:15
Copy link

codecov bot commented May 22, 2024

Codecov Report

Attention: Patch coverage is 78.35052% with 21 lines in your changes are missing coverage. Please review.

Project coverage is 95.72%. Comparing base (ddce6bf) to head (2cba348).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #255      +/-   ##
==========================================
- Coverage   96.05%   95.72%   -0.33%     
==========================================
  Files          44       45       +1     
  Lines        5165     5261      +96     
==========================================
+ Hits         4961     5036      +75     
- Misses        204      225      +21     
Files Coverage Δ
nc_py_api/_session.py 96.44% <100.00%> (+0.03%) ⬆️
nc_py_api/nextcloud.py 97.99% <100.00%> (+0.04%) ⬆️
nc_py_api/loginflow_v2.py 75.58% <75.58%> (ø)

nc_py_api/loginflow_v2.py Outdated Show resolved Hide resolved
nc_py_api/loginflow_v2.py Outdated Show resolved Hide resolved
@bigcat88
Copy link
Contributor

As I understand this should be used like this:

import nc_py_api


if __name__ == "__main__":
    nc = nc_py_api.Nextcloud(nextcloud_url="http://stable29.local")
    r = nc.loginflow_v2.init()
    print(r)  # here open link in browser and agree to connect
    r2 = nc.loginflow_v2.poll(r.token)
    print(r2)
    print(nc.capabilities)
    print(nc.files.listdir())

Thank you for your pull request and interest in Nextcloud and nc_py_api, after changing the URL I will gladly merge it. :)

@bigcat88 bigcat88 merged commit 5d41bf9 into cloud-py-api:main May 22, 2024
19 checks passed
@bigcat88
Copy link
Contributor

Thanks again, good job :)

@blvdek
Copy link
Contributor Author

blvdek commented May 22, 2024

Thank you too

@blvdek blvdek deleted the feat/loginflow_v2 branch May 22, 2024 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants