How to use the google-auth-library.UserRefreshClient function in google-auth-library

To help you get started, we’ve selected a few google-auth-library examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github actions-on-google / actions-on-google-testing-nodejs / actions-on-google.js View on Github external
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;
    }
github actions-on-google / actions-on-google-testing-nodejs / src / actions-on-google.ts View on Github external
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
    }
github yoichiro / actions-tools / src / conversation.ts View on Github external
_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,
        )
    }