Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createClient_(credentials) {
const sslCreds = grpc.credentials.createSsl();
// https://github.com/google/google-auth-library-nodejs/blob/master/ts/lib/auth/refreshclient.ts
const refresh = new UserRefreshClient();
refresh.fromJSON(credentials);
const callCreds = grpc.credentials.createFromGoogleCredential(refresh);
const combinedCreds = grpc.credentials.combineChannelCredentials(sslCreds, callCreds);
const client = new embedded_assistant_pb.EmbeddedAssistant(this.endpoint_, combinedCreds);
return client;
}
process.env.ACTIONS_TESTING_REFRESH_TOKEN) {
credentials = {
client_id: process.env.ACTIONS_TESTING_CLIENT_ID,
client_secret: process.env.ACTIONS_TESTING_CLIENT_SECRET,
refresh_token: process.env.ACTIONS_TESTING_REFRESH_TOKEN,
type: 'authorized_user',
}
} else {
throw new Error(
'Please provide ACTIONS_TESTING_CLIENT_ID,'
+ ' ACTIONS_TESTING_CLIENT_SECRET,'
+ ' ACTIONS_TESTING_REFRESH_TOKEN environment variables.')
}
}
const sslCreds = grpc.credentials.createSsl()
const refresh = new UserRefreshClient()
refresh.fromJSON(credentials)
const callCreds = grpc.credentials.createFromGoogleCredential(refresh)
const combinedCreds = grpc.credentials.combineChannelCredentials(sslCreds, callCreds)
const client = new embeddedAssistantPb.EmbeddedAssistant(this._endpoint, combinedCreds)
return client
}
_createAssistant(tokenInfo: TokenInfo) {
let channelCredentials = grpc.credentials.createSsl()
const userRefreshClient = new UserRefreshClient()
userRefreshClient.fromJSON(tokenInfo)
const googleCredential = grpc.credentials.createFromGoogleCredential(userRefreshClient)
channelCredentials = grpc.credentials.combineChannelCredentials(channelCredentials, googleCredential)
return new embeddedAssistantProtocolBuffer.EmbeddedAssistant(
"embeddedassistant.googleapis.com",
channelCredentials,
)
}