CreateAppKey Method

Creates a new application key.

Syntax

QString CreateAppKey(const QString& qsKeyName, const QString& qsCapabilities, const QString& qsAllowedBucketId, const QString& qsAllowedPrefix, qint64 lValidityDuration);

Remarks

This method creates a new application key named KeyName with the specified Capabilities. If successful, this method returns a string containing the newly-created application key's Id, followed by the key itself, separated by a newline (\n) character; for example:

[application_key_id]
[application_key]
Important: This is the only time that the application key's key string will be returned, be sure to save it immediately. It is not present in the results returned by the ListAppKeys method (this is a security feature enforced by the server).

The string passed for Capabilities must be formatted as a comma-separated list of one or more of the following:

Capability String Related Methods
deleteBuckets DeleteBucket
deleteFiles DeleteFile, DeleteFileVersion
deleteKeys DeleteAppKey
listBuckets GetBucketInfo, ListBuckets
listFiles DeleteFile, ListFiles, ListFileVersions, ListMultipartUploads
listKeys ListAppKeys
readFiles CopyFile, CopyPart, DownloadFile, DownloadFileById, GetFileInfo
shareFiles GetDownloadAuthToken
writeBuckets CreateBucket, UpdateBucket
writeFiles AbortMultipartUpload, CompleteMultipartUpload, CopyFile, CopyPart, HideFile, ListParts, StartMultipartUpload, UploadFile, UploadPart
writeKeys CreateAppKey

To restrict the new application key to a specific bucket, pass the bucket's Id for AllowedBucketId. To further restrict it to files with a specific prefix within that bucket, pass said prefix for AllowedPrefix. It is not possible to apply a prefix restriction without a bucket restriction.

The ValidityDuration parameter specifies how many seconds the new application key will be valid for. The maximum valid value is 86400000 (1000 days); values less than 1 will cause the application key to remain valid indefinitely.

The currently-authenticated application key must have the writeKeys capability to call this method successfully, otherwise the server will return an error. Refer to the AccountCapabilities property for more information.

Error Handling

This method returns a String value; after it returns, call the GetLastErrorCode() method to obtain its result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks Cloud 2020 Qt Edition - Version 20.0 [Build 8265]