DialogFlow v2 Access Token cannot generate

前端 未结 3 772
借酒劲吻你
借酒劲吻你 2021-01-14 01:42

With version 1 this is how I used to communicate with DialogFlow Api!

fetch(configs.baseUrl + \"query?v=20150910\", {
    body: JSON.stringify({query: text,          


        
3条回答
  •  青春惊慌失措
    2021-01-14 02:16

    Below is another example of creating your DialogFlow V2 access token using Node.js. The library that is used in the code below is google-oauth-jwt.

    const googleAuth = require('google-oauth-jwt');
    
    function generateAccessToken() {
     return new Promise((resolve) => {
      googleAuth.authenticate(
       {
        email: ,
        key: ,
        scopes: 'https://www.googleapis.com/auth/cloud-platform',
       },
       (err, token) => {
        resolve(token);
       },
      );
     });
    }
    

    You may find your client_email and private_key from the JSON key file you have downloaded from your Google Cloud Platform project's service account page. If you are unsure how/where to download it, you may checkout my blog post here.

    To find out which scope which scope you may need, you may checkout the DialogFlow V2 REST API documentation page.

提交回复
热议问题