List passwords
  • 3 minutes to read
  • Dark
    Light
  • PDF

List passwords

  • Dark
    Light
  • PDF

Article summary

This article presents how to access password 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 passwords

Request

To access a list with all the passwords stored in MySafe, send a request to the following endpoint:

GET /api/mysafe/password

Request parameters

Query

FieldTypeRequiredDescriptionExample
tagStringNoSearches for all the passwords registered with a specific tag.test

Return

Returns the passwords 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
    },
    "password_on_list": 
        {
            "identifier": "197",
            "name": "Testing",
            "url": "www.url.com",
            "username": "maria",
            "tags": "test",
            "need_justify": "0",
            "need_approval": "0",
            "can_view": true,
            "can_write": true
        },
        {
            "identifier": "198",
            "name": "API",
            "url": "",
            "username": "dleite",
            "tags": "api",
            "need_justify": "0",
            "need_approval": "0",
            "can_view": true,
            "can_write": true
        },
        {
            "identifier": "226",
            "name": "Gmail",
            "url": "www.gmail.com",
            "username": "dleite",
            "tags": "gmail",
            "need_justify": "0",
            "need_approval": "0",
            "can_view": true,
            "can_write": true
        }
    ]
}

List a password

Request

To access a password stored in MySafe, send a request to the following endpoint:

GET /api/mysafe/password/[identifier]

Request parameters

Path

FieldTypeRequiredDescriptionExample
identifierStringYesUnique code identifier associated with each entry in the password table. This value is automatically assigned by senhasegura when creating a password.197

Return

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

Response parameters

FieldTypeDescriptionExample
identifierStringUnique code identifier associated with each entry in the password table. This value is automatically assigned by senhasegura when creating a password.197
nameStringName assigned to the password.Testing
urlStringURL of the website where the password is being used.www.url.com
usernameStringUsername used to access the account.maria
passwordStringThe password accessible to your user.Cs^Q4PdbIOo4
secret_keyStringThe secret key provided by the service for multi-factor authentication.JBSWY3DPEHPK3PXP
tokenStringTOTP code, automatically generated by senhasegura for multi-factor authentication based on the token provided when creating or updating a password.452180
notesStringObservations about the password.This is a test password.
tagsStringKeywords to help identify the password.test
users_allowedArray of objectsInformation about the users allowed to access the password. Note: an empty array means the password hasn’t been shared.
usernameStringUsername of the user who can access the password.
can_editBooleanEditing permission. If left empty, the user will have only viewing permission.
groups_allowedArray of objectsInformation about the groups allowed to access the password. Note: an empty array means the password hasn’t been shared.
nameStringName of the group that can access the password.
can_editBooleanEditing permission. If left empty, group members will have only viewing permission.

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
    },
    "password_entity": {
        "identifier": "197",
        "name": "Testing",
        "url": "www.url.com",
        "username": "maria",
        "password": "Cs^Q4PdbIOo4",
        "secret_key": JBSWY3DPEHPK3PXP,
        "token": 452180,
        "notes": "This is a test password",
        "tags": "test",
        "users_allowed": [],
        "groups_allowed": []
    }
}

In case of error - password not found

HTTP/1.1 400 Bad Request
{
    "response": {
        "status": 400,
        "mensagem": "1005: Password not found",
        "erro": true,
        "cod_erro": 0,
        "message": "1005: Password not found",
        "error": true,
        "error_code": 0
    },
    "exception": {
        "code": 1005,
        "message": "1005: Password not found",
        "detail": ""
    }
}

In case of error - user has no access to the password

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

Was this article helpful?