Module: src/credentials

Credentials module This module contains factory methods for two different credential types: CallCredentials and ChannelCredentials. ChannelCredentials are things like SSL credentials that can be used to secure a connection, and are used to construct a Client object. CallCredentials genrally modify metadata, so they can be attached to an individual method call. CallCredentials can be composed with other CallCredentials to create CallCredentials. ChannelCredentials can be composed with CallCredentials to create ChannelCredentials. No combined credential can have more than one ChannelCredentials. For example, to create a client secured with SSL that uses Google default application credentials to authenticate: var channel_creds = credentials.createSsl(root_certs); (new GoogleAuth()).getApplicationDefault(function(err, credential) { var call_creds = credentials.createFromGoogleCredential(credential); var combined_creds = credentials.combineChannelCredentials( channel_creds, call_creds); var client = new Client(address, combined_creds); });
Source:

Members

(static) createInsecure

Create an insecure credentials object. This is used to create a channel that does not use SSL. This cannot be composed with anything.
Source:

(static) createSsl

Create an SSL Credentials object. If using a client-side certificate, both the second and third arguments must be passed.
Source:

Methods

(static) combineCallCredentials(…credentials)

Combine any number of CallCredentials into a single CallCredentials object
Parameters:
Name Type Attributes Description
credentials CallCredentials <repeatable>
the CallCredentials to compose
Source:
Returns:
CallCredentials A credentials object that combines all of the input credentials

(static) combineChannelCredentials(channel_credential, …credentials)

Combine a ChannelCredentials with any number of CallCredentials into a single ChannelCredentials object.
Parameters:
Name Type Attributes Description
channel_credential ChannelCredentials The ChannelCredentials to start with
credentials CallCredentials <repeatable>
The CallCredentials to compose
Source:
Returns:
ChannelCredentials A credentials object that combines all of the input credentials

(static) createFromGoogleCredential(google_credential) → {CallCredentials}

Create a gRPC credential from a Google credential object.
Parameters:
Name Type Description
google_credential Object The Google credential object to use
Source:
Returns:
The resulting credentials object
Type
CallCredentials

(static) createFromMetadataGenerator(metadata_generator) → {CallCredentials}

Create a gRPC credentials object from a metadata generation function. This function gets the service URL and a callback as parameters. The error passed to the callback can optionally have a 'code' value attached to it, which corresponds to a status code that this library uses.
Parameters:
Name Type Description
metadata_generator function The function that generates metadata
Source:
Returns:
The credentials object
Type
CallCredentials