List API secrets
  • 3 minutes to read
  • Dark
    Light
  • PDF

List API secrets

  • Dark
    Light
  • PDF

Article summary

This article presents how to access API secret information from MySafe via API, the available endpoints, the parameters needed, example requests, and responses on success or in case of errors.

Authorization

The authorization for MySafe APIs is performed directly in the module. For more information, access the How to add an access key authorization document.

Authentication

Authentication in the MySafe APIs is conducted using the OAuth 2.0 authentication method. To initiate this process, users need to provide the Client ID and Client Secret, as well as obtain their authentication token from the endpoint:

GET /api/oauth2/token

For more information on how to obtain the Client ID and the Client Secret, access the How to view an access key authorization document.

Methods

List all API secrets

Request

To access a list of all the API secrets stored in MySafe, send a request to the following endpoint:

GET /api/mysafe/secretapi

Request parameters

Query

FieldTypeRequiredDescriptionExample
tagstringNoSearches for all API secrets identified by a specific tag.test
identifier_codestringNoSearches for an API secret based on its identifier_code. This code is created by the user when creating an API secret. Note: do not confuse it with the identifier parameter which is automatically generated by senhasegura and is associated with each entry in the API secret table.

Return

Returns the API secrets associated with your user's access in MySafe, and provides a message with information about the retrieval process.

Expected response

HTTP/1.1 200 OK
{
    "code": 200,
    "response": {
        "status": 200,
        "message": "",
        "error": false,
        "error_code": 0,
        "detail": "",
        "mensagem": "",
        "erro": false,
        "cod_erro": 0
    },
    "api_secret_on_list": [
        {
            "identifier": "14",
            "name": "Teste",
            "need_justify": "0",
            "need_approval": "0",
            "can_view": true,
            "can_write": true
        },
        {
            "identifier": "40",
            "name": "My API secret",
            "need_justify": "0",
            "need_approval": "0",
            "can_view": true,
            "can_write": true
        }
    ]
}


List an API secret

Request

To access an API secret stored in MySafe, send a request to the following endpoint:

GET /api/mysafe/secretapi/[identifier]

Request parameters

Path

FieldTypeRequiredDescriptionExample
identifierStringYesUnique identifier code associated with each entry in the API secret table. This value is automatically assigned by senhasegura when creating an API secret. Note: do not confuse it with the identifier_code parameter which is created by the user when creating an API secret.40

Return

Returns the API secret associated with your user's access in MySafe, based on its identifier, and provides a message with information about the retrieval process.

Expected response

HTTP/1.1 200 OK

{
    "code": 200,
    "response": {
        "status": 200,
        "message": "Success",
        "error": false,
        "error_code": 0,
        "detail": "",
        "mensagem": "Success",
        "erro": false,
        "cod_erro": 0
    },
    "api_secret_entity": {
        "identifier": "40",
        "name": "My API secret",
        "url": "www.url.com",
        "client_secret": "dq986483917r56e997",
        "client_id": "jdpidnbpchje6y76egh",
        "identifier_code": "dfqw45d",
        "method": "get",
        "tags": "secret",
        "notes": "My API secret",
        "users_allowed": [
            {
                "name": "pduarte",
                "can_edit": false
            }
        ],
        "groups_allowed": [
            {
                "name": "Test group",
                "can_edit": false
            }
        ]
    }
}

In case of error - user has no access to this API secret

HTTP/1.1 400 Bad Request

{
    "code": 400,
    "response": {
        "status": 400,
        "message": "1006: User does not have access",
        "error": true,
        "error_code": 1,
        "detail": "",
        "mensagem": "1006: User does not have access",
        "erro": true,
        "cod_erro": 1
    },
    "exception": {
        "code": 1006,
        "message": "1006: User does not have access",
        "detail": null
    }
}

In case of error - API secret not found

HTTP/1.1 400 Bad Request

{
    "code": 400,
    "response": {
        "status": 400,
        "message": "1005: API secret not found",
        "error": true,
        "error_code": 1,
        "detail": "",
        "mensagem": "1005: API secret not found",
        "erro": true,
        "cod_erro": 1
    },
    "exception": {
        "code": 1005,
        "message": "1005: API secret not found",
        "detail": null
    }
}

In case of error - inactive API secret

HTTP/1.1 400 Bad Request

{
    "code": 400,
    "response": {
        "status": 400,
        "message": "1009: Inactive api secret",
        "error": true,
        "error_code": 1,
        "detail": "",
        "mensagem": "1009: Inactive api secret",
        "erro": true,
        "cod_erro": 1
    },
    "exception": {
        "code": 1009,
        "message": "1009: Inactive api secret",
        "detail": null
    }
}

Was this article helpful?