Skip to content

credentials

Credentials

Bases: ListableApiResource, FindableApiResource, CreatableApiResource, UpdatableApiResource, DestroyableApiResource

Nylas Credentials API

A Nylas connector credential is a special type of record that securely stores information that allows you to connect using an administrator account

Source code in nylas/resources/credentials.py
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
class Credentials(
    ListableApiResource,
    FindableApiResource,
    CreatableApiResource,
    UpdatableApiResource,
    DestroyableApiResource,
):
    """
    Nylas Credentials API


    A Nylas connector credential is a special type of record that securely stores information
    that allows you to connect using an administrator account
    """

    def list(
        self, provider: Provider, query_params: ListCredentialQueryParams = None
    ) -> ListResponse[Credential]:
        """
        Return all credentials for a particular provider.

        Args:
            provider: The provider.
            query_params: The query parameters to include in the request.

        Returns:
            The list of credentials.
        """

        return super().list(
            path=f"/v3/connectors/{provider}/creds",
            response_type=Credential,
            query_params=query_params,
        )

    def find(self, provider: Provider, credential_id: str) -> Response[Credential]:
        """
        Return a credential.

        Args:
            provider: The provider of the credential.
            credential_id: The ID of the credential to retrieve.

        Returns:
            The Credential.
        """

        return super().find(
            path=f"/v3/connectors/{provider}/creds/{credential_id}",
            response_type=Credential,
        )

    def create(
        self, provider: Provider, request_body: CredentialRequest
    ) -> Response[Credential]:
        """
        Create a credential for a particular provider.

        Args:
            provider: The provider.
            request_body: The values to create the Credential with.

        Returns:
            The created Credential.
        """

        return super().create(
            path=f"/v3/connectors/{provider}/creds",
            response_type=Credential,
            request_body=request_body,
        )

    def update(
        self,
        provider: Provider,
        credential_id: str,
        request_body: UpdateCredentialRequest,
    ) -> Response[Credential]:
        """
        Update a credential.

        Args:
            provider: The provider.
            credential_id: The ID of the credential to update.
            request_body: The values to update the credential with.

        Returns:
            The updated credential.
        """

        return super().update(
            path=f"/v3/connectors/{provider}/creds/{credential_id}",
            response_type=Credential,
            request_body=request_body,
            method="PATCH",
        )

    def destroy(self, provider: Provider, credential_id: str) -> DeleteResponse:
        """
        Delete a credential.

        Args:
            provider: the provider for the grant
            credential_id: The ID of the credential to delete.

        Returns:
            The deletion response.
        """

        return super().destroy(path=f"/v3/connectors/{provider}/creds/{credential_id}")

create(provider, request_body)

Create a credential for a particular provider.

Parameters:

Name Type Description Default
provider Provider

The provider.

required
request_body CredentialRequest

The values to create the Credential with.

required

Returns:

Type Description
Response[Credential]

The created Credential.

Source code in nylas/resources/credentials.py
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
def create(
    self, provider: Provider, request_body: CredentialRequest
) -> Response[Credential]:
    """
    Create a credential for a particular provider.

    Args:
        provider: The provider.
        request_body: The values to create the Credential with.

    Returns:
        The created Credential.
    """

    return super().create(
        path=f"/v3/connectors/{provider}/creds",
        response_type=Credential,
        request_body=request_body,
    )

destroy(provider, credential_id)

Delete a credential.

Parameters:

Name Type Description Default
provider Provider

the provider for the grant

required
credential_id str

The ID of the credential to delete.

required

Returns:

Type Description
DeleteResponse

The deletion response.

Source code in nylas/resources/credentials.py
115
116
117
118
119
120
121
122
123
124
125
126
127
def destroy(self, provider: Provider, credential_id: str) -> DeleteResponse:
    """
    Delete a credential.

    Args:
        provider: the provider for the grant
        credential_id: The ID of the credential to delete.

    Returns:
        The deletion response.
    """

    return super().destroy(path=f"/v3/connectors/{provider}/creds/{credential_id}")

find(provider, credential_id)

Return a credential.

Parameters:

Name Type Description Default
provider Provider

The provider of the credential.

required
credential_id str

The ID of the credential to retrieve.

required

Returns:

Type Description
Response[Credential]

The Credential.

Source code in nylas/resources/credentials.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
def find(self, provider: Provider, credential_id: str) -> Response[Credential]:
    """
    Return a credential.

    Args:
        provider: The provider of the credential.
        credential_id: The ID of the credential to retrieve.

    Returns:
        The Credential.
    """

    return super().find(
        path=f"/v3/connectors/{provider}/creds/{credential_id}",
        response_type=Credential,
    )

list(provider, query_params=None)

Return all credentials for a particular provider.

Parameters:

Name Type Description Default
provider Provider

The provider.

required
query_params ListCredentialQueryParams

The query parameters to include in the request.

None

Returns:

Type Description
ListResponse[Credential]

The list of credentials.

Source code in nylas/resources/credentials.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
def list(
    self, provider: Provider, query_params: ListCredentialQueryParams = None
) -> ListResponse[Credential]:
    """
    Return all credentials for a particular provider.

    Args:
        provider: The provider.
        query_params: The query parameters to include in the request.

    Returns:
        The list of credentials.
    """

    return super().list(
        path=f"/v3/connectors/{provider}/creds",
        response_type=Credential,
        query_params=query_params,
    )

update(provider, credential_id, request_body)

Update a credential.

Parameters:

Name Type Description Default
provider Provider

The provider.

required
credential_id str

The ID of the credential to update.

required
request_body UpdateCredentialRequest

The values to update the credential with.

required

Returns:

Type Description
Response[Credential]

The updated credential.

Source code in nylas/resources/credentials.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
def update(
    self,
    provider: Provider,
    credential_id: str,
    request_body: UpdateCredentialRequest,
) -> Response[Credential]:
    """
    Update a credential.

    Args:
        provider: The provider.
        credential_id: The ID of the credential to update.
        request_body: The values to update the credential with.

    Returns:
        The updated credential.
    """

    return super().update(
        path=f"/v3/connectors/{provider}/creds/{credential_id}",
        response_type=Credential,
        request_body=request_body,
        method="PATCH",
    )