cloud-py-api / nc_py_api

Nextcloud Python Framework
https://cloud-py-api.github.io/nc_py_api/
Other
84 stars 4 forks source link

feat: Login flow v2 #255

Closed blvdek closed 3 months ago

blvdek commented 3 months ago

Changes proposed in this pull request:

bigcat88 commented 3 months ago

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 commented 3 months ago

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.

codecov[bot] commented 3 months ago

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 ```diff @@ 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](https://app.codecov.io/gh/cloud-py-api/nc_py_api/pull/255?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloud-py-api) | Coverage Δ | | |---|---|---| | [nc\_py\_api/\_session.py](https://app.codecov.io/gh/cloud-py-api/nc_py_api/pull/255?src=pr&el=tree&filepath=nc_py_api%2F_session.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloud-py-api#diff-bmNfcHlfYXBpL19zZXNzaW9uLnB5) | `96.44% <100.00%> (+0.03%)` | :arrow_up: | | [nc\_py\_api/nextcloud.py](https://app.codecov.io/gh/cloud-py-api/nc_py_api/pull/255?src=pr&el=tree&filepath=nc_py_api%2Fnextcloud.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloud-py-api#diff-bmNfcHlfYXBpL25leHRjbG91ZC5weQ==) | `97.99% <100.00%> (+0.04%)` | :arrow_up: | | [nc\_py\_api/loginflow\_v2.py](https://app.codecov.io/gh/cloud-py-api/nc_py_api/pull/255?src=pr&el=tree&filepath=nc_py_api%2Floginflow_v2.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=cloud-py-api#diff-bmNfcHlfYXBpL2xvZ2luZmxvd192Mi5weQ==) | `75.58% <75.58%> (ø)` | |
bigcat88 commented 3 months ago

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 commented 3 months ago

Thanks again, good job :)

blvdek commented 3 months ago

Thank you too