Could not load the default credentials? (Node.js Google Compute Engine tutorial)

后端 未结 14 1530
情话喂你
情话喂你 2020-12-04 19:20

SITUATION:

I follow this tutorial: https://cloud.google.com/nodejs/tutorials/bookshelf-on-compute-engine

Everything works fine until I do

相关标签:
14条回答
  • 2020-12-04 19:39

    Although this question has been answered multiple times, I found myself in a situation not explained here.

    After I created the variable: $GOOGLE_APPLICATION_CREDENTIALS, I was getting the same error as Coder1000.

    However, I was running both: nodemon and: npm run dev in two separate sessions in Terminal, neither of which were aware of the variable.

    Once I: shut the tabs down; added new tabs; and ran the commands again, the application was able to access the variable.

    0 讨论(0)
  • 2020-12-04 19:41

    For all people using firebase, what it worked for me was passing the credentials to the KeyManagementServiceClient constructor

    const serviceAccount = require('../keys/file.json'); //<- your firebase credentials
    const client = new KeyManagementServiceClient({
          credentials: serviceAccount,
        });
    
    0 讨论(0)
  • 2020-12-04 19:42

    You have to create an object of your SessionsClient. Here I will provide some steps, so you can run your code like a charm.

    1. You have to go into your Dialogflow dashboard.
    2. Click on setting ( Left navbar top-right gear icon)
    3. in the General tab click Service Account link ( it will redirect you to another screen)
    4. If you have a service account then ignore step 5
    5. Create a service account ( Top-center +icon button)
      • Now you have a service account on a list click on
    6. From the action, field presses the 3 vertical dots and create a key.
    7. Download the JSON file on your local computer.
    8. Assign object to your sessionClient.
    const sessionClient = new dialogflow.SessionsClient({
     keyFilename: "/var/www/html/moqatrips/dialog-flow.json"
    });
    
    0 讨论(0)
  • 2020-12-04 19:43

    you may find youself in another part of the world -- and land here. I'm adding to a three year old question because its keywords matched my issue and the preceding answers helped me although none describe my issue

    firebase deploy --only functions --debug
    

    produced

    [2020-12-02T08:31:50.397Z] FirebaseError: HTTP Error: 429, Unknown Error
    Error: Could not read source directory. Remove links and shortcuts and try again.
    

    I could not find anything wrong with the source directory. But that was all so many tiny fish.

    Examining the error in detail, from the top, lead to:

    Our systems have detected unusual traffic from your computer network.  This page checks to see if it&#39;s really you sending the requests, and not a robot. 
    The block will expire shortly after those requests stop.  
    

    Out of curiosity and exhaustion, I waited first. The wait reset duration is > than 30 minutes. So i pursued the captcha to prove my enduring humanity which did register eventually after some oauth warnings.

    0 讨论(0)
  • 2020-12-04 19:45

    Go here: https://firebase.google.com/docs/admin/setup#initialize_the_sdk and follow the instructions to create a private key. Then after you have downloaded your private key open command prompt in the project directory and do the following command:

     set GOOGLE_APPLICATION_CREDENTIALS=C:\YOUR-PATH\YOUR-KEY.json
    
    0 讨论(0)
  • 2020-12-04 19:45

    I also had this error problem, here I had not created the object of

    keyFilename (stores the credentials of the api)

    in the sessionClient object for nodejs app.

    const sessionClient = new dialogflow.SessionsClient({
                    keyFilename: "./keyCredentials.json"  
           });
            
               const sessionPath = sessionClient.sessionPath(projectId, sessionId);

    To download 'keyCredentials.json' goto:

    https://console.cloud.google.com/apis/credentials/serviceaccountkey

    Also add the path of this file to the system variables

    1. In windows open powershell
    2. type GOOGLE_APPLICATION_CREDENTIALS = [PATH_TO_SERVICE_ACCOUNT_JSON_FILE]
    0 讨论(0)
提交回复
热议问题