Documentation ¶
Overview ¶
Package pcloud provides a client for accessing the pCloud API.
The pCloud API is located in the US and EU. If you are using the API it is important that you set the correct location for your account. Otherwise the authentication will fail. The default HostURL is the EU API. To change the host use the constants HostURLEU or HostURLUS. If there will be another location in the future it is also possible to set that variable with the URL. For security reasons it is not recomended to change the protocol from HTTPS to HTTP.
For the authentication there are two different methods to get the auth-token. With AuthMethodPassword the password is send to the server as a get-parameter. This way is not recomended, because it not a good idea to send a password directly to pCloud. Even when HTTPS is used. The Default method is AuthMethodDigest. In this case first a digest is requested from the api-server. This digest is used to hash the password with the username to receive an auth-token. Cause of the extra request that way is a little bit slower. But that is just once, when the auth-token is requested.
To get the data this package does just use the JSON API from pCloud. The binary API is not supported. The JSON API is documented here: https://docs.pcloud.com/methods/
Index ¶
Constants ¶
const ( HostURLEU = "https://eapi.pcloud.com" HostURLUS = "https://api.pcloud.com" )
The different host URLs of the pCloud API. The URL can be setz with the HostURL variable. If there will be a new host URL, it can be set with the HostURL variable. The HostURL variable is set to the HostURLEU variable by default.
const ( AuthMethodPassword = iota // Send password as get parameter AuthMethodDigest // Send a hashed password as get parameter )
The different authentication methods, which can be used to authenticate with the pCloud API. The AuthMethodPassword method sends the password as parameters. So it is not recomendet to use this method, because the password is sent in plain text. The AuthMethodDigest method sends the password as a hashed string. To do this a digest value is requested from the pCloud API.
Variables ¶
var ( HostURL = HostURLEU // HostURL is the base URL for the pCloud API. AuthMethod = AuthMethodDigest // AuthMethod is the method used to authenticate with the pCloud API. Timeout = 5 * time.Second // Timeout for the API requests )
The global configuration variables of the pCloud API.
var HTTPClient = &http.Client{ Timeout: Timeout, }
HTTPClient is the HTTP client used to make requests to the pCloud API. If you want to define your own HTTP client, you can do so by setting this variable to your client. The default client uses the Timout variable of this package.
Functions ¶
func ApiRequest ¶
ApiRequest is a generic function to request data from the pCloud API It takes a pointer to a struct as response and a method name and a list of parameters. Into the respStuct the JSON response is decoded.
This function uses the authToken variable to authenticate the request. If the authToken is not set, the user needs to be logged in.
func AuthToken ¶
func AuthToken() string
AuthToken returns the authentication token used to authenticate with the pCloud API.
Types ¶
Directories ¶
Path | Synopsis |
---|---|
Package api is the structure of the JSON returned by the pCloud API.
|
Package api is the structure of the JSON returned by the pCloud API. |
Package pfs implements the pCloud API as a fs.FS interface At the moment this is a prototype and should not be used by other packages! Because the API is not stable yet and the implementation is not complete.
|
Package pfs implements the pCloud API as a fs.FS interface At the moment this is a prototype and should not be used by other packages! Because the API is not stable yet and the implementation is not complete. |