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
 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
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,
        overrides: RequestOverrides = None,
    ) -> ListResponse[Credential]:
        """
        Return all credentials for a particular provider.

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

        Returns:
            The list of credentials.
        """

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

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

        Args:
            provider: The provider of the credential.
            credential_id: The ID of the credential to retrieve.
            overrides: The request overrides to use for the request.

        Returns:
            The Credential.
        """

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

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

        Args:
            provider: The provider.
            request_body: The values to create the Credential with.
            overrides: The request overrides to use for the request.

        Returns:
            The created Credential.
        """

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

    def update(
        self,
        provider: Provider,
        credential_id: str,
        request_body: UpdateCredentialRequest,
        overrides: RequestOverrides = None,
    ) -> 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.
            overrides: The request overrides to use for the request.

        Returns:
            The updated credential.
        """

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

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

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

        Returns:
            The deletion response.
        """

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

create(provider, request_body, overrides=None)

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
overrides RequestOverrides

The request overrides to use for the request.

None

Returns:

Type Description
Response[Credential]

The created Credential.

Source code in nylas/resources/credentials.py
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
def create(
    self,
    provider: Provider,
    request_body: CredentialRequest,
    overrides: RequestOverrides = None,
) -> Response[Credential]:
    """
    Create a credential for a particular provider.

    Args:
        provider: The provider.
        request_body: The values to create the Credential with.
        overrides: The request overrides to use for the request.

    Returns:
        The created Credential.
    """

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

destroy(provider, credential_id, overrides=None)

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
overrides RequestOverrides

The request overrides to use for the request.

None

Returns:

Type Description
DeleteResponse

The deletion response.

Source code in nylas/resources/credentials.py
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
def destroy(
    self,
    provider: Provider,
    credential_id: str,
    overrides: RequestOverrides = None,
) -> DeleteResponse:
    """
    Delete a credential.

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

    Returns:
        The deletion response.
    """

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

find(provider, credential_id, overrides=None)

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
overrides RequestOverrides

The request overrides to use for the request.

None

Returns:

Type Description
Response[Credential]

The Credential.

Source code in nylas/resources/credentials.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
def find(
    self,
    provider: Provider,
    credential_id: str,
    overrides: RequestOverrides = None,
) -> Response[Credential]:
    """
    Return a credential.

    Args:
        provider: The provider of the credential.
        credential_id: The ID of the credential to retrieve.
        overrides: The request overrides to use for the request.

    Returns:
        The Credential.
    """

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

list(provider, query_params=None, overrides=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
overrides RequestOverrides

The request overrides to use for the request.

None

Returns:

Type Description
ListResponse[Credential]

The list of credentials.

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

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

    Returns:
        The list of credentials.
    """

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

update(provider, credential_id, request_body, overrides=None)

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
overrides RequestOverrides

The request overrides to use for the request.

None

Returns:

Type Description
Response[Credential]

The updated credential.

Source code in nylas/resources/credentials.py
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
def update(
    self,
    provider: Provider,
    credential_id: str,
    request_body: UpdateCredentialRequest,
    overrides: RequestOverrides = None,
) -> 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.
        overrides: The request overrides to use for the request.

    Returns:
        The updated credential.
    """

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