Authentication
There are two ways to authenticate: API Key authentication and Session-based authentication.
Authenticate with an API Key
Authenticating with an API key is the recommended authentication method for most scenarios, and is the method used in the examples on this site.
To use an API Key, first generate an API key from the web interface or via the API or an SDK.
A user key follows its account's permissions, narrowed by the key's permission scope, Workspace, and any path restriction on file operations. It can perform administrative operations only when both the account and key permit them. API Keys explains credential scope and lifecycle; Workspaces explains request context and delegated administration.
Noteworthy
Don't forget to replace the placeholder, YOUR_API_KEY, with your actual API key.
Authenticate with a Session
Create a session with the username and password of an active user. The session uses that user's permissions, including any delegated administrative access. Workspaces describes account scope and administrative access.
Sessions use the same timeout settings as sessions in the web interface. When a session expires, create a new one and use it to authenticate subsequent SDK calls. The SDK does not renew sessions automatically because doing so would require keeping your password in memory without your explicit consent.
Logging In
To create a session, call files_sdk.session.create(), or a client's client.session.create(), with
the user's username and password.
This returns a session object that can be used to authenticate SDK method calls, including as a
client's session setting. Closing a client does not log out its session.
Using a Session
Once you have created a session, you can configure it globally or use it to authenticate a particular object or request.
Logging Out
To end a user session, call session.destroy() on the session object returned when you logged in.