I'm currently studying the pCloud API and have a couple of specific questions regarding its usage:
Q1.
Use the userinfo API with your access token and you'll get an instant response.
import requests
account_url = "https://api.pcloud.com/userinfo"
access_token ="ACCESS TOKEN"
response = requests.get(account_url, headers={ "Authorization": f"Bearer {access_token}", })your text
account_info = response.json() print(account_info)
However, if you use listtokens API instead of userinfo API, you will receive {'result': 1000, 'error': 'Log in required.'}
response.
Is there a way to use the listtokens API using an access token?
I know that I can use authentication token as below. (https://api.pcloud.com/listtokens?auth={Authentication token})
Q2.
Or is there a way to obtain an authentication token using an access token? (other than using passworddigest)
I contacted the pcloud support team and was told to only look at docs.pcloud.com
Get solutions and USE API
Answer 1: It is unfortunately impossible to use the
listtokens
-endpoint with the OAuth2 authentication method. It is only possible with the username/password-authentication method. See the discussion here https://github.com/tomgross/pcloud/issues/61Answer 2: Look at the authentication methods implemented in the pcloud python api (https://github.com/tomgross/pcloud/blob/master/src/pcloud/api.py#L100). It implements all authentication methods. For the OAuth-flow you will need a browser, which can be headless.
I'm the author of the pCloud API written in Python (https://pypi.org/project/pcloud/) and I am not associated with the pCloud company.