b2_authorize_account
    • Dark
      Light

    b2_authorize_account

    • Dark
      Light

    Article Summary

    Get
    /b2api/v2/b2_authorize_account

    Returns an authorization token

    Used to log in to the B2 API. Returns an authorization token that can be used for subsequent API calls, and a URL that should be used as the base URL for subsequent API calls.


    You can use either the master application key or a normal application key.


    NOTE the account ID can be used in place of the master application key ID.


    You'll find the master application key in the Backblaze web UI. When using the master application key, use your "master application key ID" and the "application key" you got from the site.


    Master Application Key This is the first key you have access to, it is available in the Backblaze web UI. This key has all capabilities, access to all buckets, and has no file prefix restrictions or expiration.


    Application Key(s) [non-master] These are other keys created by you and can be limited to a bucket, with a specific file prefix and can expire.


    Normal application keys come from the b2_create_key call. When using one of them, the "application key ID" and "application key" are the ones returned when you created the key.

    API Versions

    v2 Return bucket name (Sept 13, 2018)

    When using an application key with a bucket restriction, the name of the bucket is now returned.

    Header parameters
    Authorization
    stringRequired

    An HTTP basic auth value constructed as follows:

    • The application key id and application key are combined into a string in the format "applicationKeyId:applicationKey".
    • The combined string is Base64 encoded.
    • "Basic" is put before the encoded string.
    Responses
    200

    The request succeeded.

    Expand All
    object
    accountId
    string

    The identifier for the account.

    ExampleYOUR_ACCOUNT_ID
    authorizationToken
    string

    An authorization token to use with all calls, other than b2_authorize_account, that need an Authorization header. This authorization token is valid for at most 24 hours.

    Example4_0022623512fc8f80000000001_0186e431_d18d02_acct_tH7VW03boebOXayIc43-sxptpfA=
    allowed
    object

    An object (see below) containing the capabilities of this auth token, and any restrictions on using it.

    capabilities
    Array of string

    A list of strings, each one naming a capability the key has. Possibilities are: listKeys, writeKeys, deleteKeys, listBuckets, writeBuckets, deleteBuckets, listFiles, readFiles, shareFiles, writeFiles, and deleteFiles.

    string
    Valid values[ "listKeys", "writeKeys", "deleteKeys", "listBuckets", "writeBuckets", "deleteBuckets", "listFiles", "readFiles", "shareFiles", "writeFiles", "deleteFiles" ]
    bucketId
    string

    When present, access is restricted to one bucket.

    bucketName
    string

    When bucketId is set, and it is a valid bucket that has not been deleted, this field is set to the name of the bucket. It's possible that bucketId is set to a bucket that no longer exists, in which case this field will be null. It's also null when bucketId is null.

    namePrefix
    string

    When present, access is restricted to files whose names start with the prefix

    apiUrl
    string

    The base URL to use for all API calls except for uploading and downloading files.

    Examplehttps://apiNNN.backblazeb2.com
    downloadUrl
    string

    The base URL to use for downloading files.

    recommendedPartSize
    integer

    The recommended size for each part of a large file. We recommend using this part size for optimal.

    Example100000000
    absoluteMinimumPartSize
    integer

    The smallest possible size of a part of a large file (except the last one). This is smaller than the recommendedPartSize. If you use it, you may find that it takes longer overall to upload a large file.

    Example5000000
    minimumPartSize
    integer

    DEPRECATED: This field will always have the same value as recommendedPartSize. Use recommendedPartSize instead.

    Example
    s3ApiUrl
    string

    The base URL to use for all API calls using the S3 compatible API.

    Examplehttps://s3.us-west-NNN.backblazeb2.com
    400
    statuscodedescription
    400bad_bucket_idThe requested bucket ID does not match an existing bucket.
    400bad_requestThe request had the wrong fields or illegal values. The message returned with the error will describe the problem.
    object
    status
    integer

    The numeric HTTP status code. Always matches the status in the HTTP response.

    Example400
    code
    string

    A single-identifier code that identifies the error.

    Exampleinvalid_bucket_name
    message
    string

    A human-readable message, in English, saying what went wrong.

    Examplebucket name is too long
    401
    statuscodedescription
    401unauthorizedThe applicationKeyId and/or the applicationKey are wrong.
    401unsupportedThe applicationKeyId is valid, but cannot be used with this version of the B2 API. The message contains information about the problem.
    403
    statuscodedescription
    403transaction_cap_exceededTransaction cap exceeded. To increase your cap, sign in to your B2 Cloud Storage account online. Then select the Caps & Alerts link in the B2 Cloud Storage section of the sidebar.

    Was this article helpful?