Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication V2: "status": "UNAUTHENTICATED" #84

Open
pramodkumar005 opened this issue May 24, 2020 · 7 comments
Open

Authentication V2: "status": "UNAUTHENTICATED" #84

pramodkumar005 opened this issue May 24, 2020 · 7 comments

Comments

@pramodkumar005
Copy link

pramodkumar005 commented May 24, 2020

Unable to get access

 constructor(props) {
        super(props);

        Dialogflow_V2.setConfiguration(
            "your-dialogflow-project@asdf-76866.iam.gserviceaccount.com",
            '-----BEGIN PRIVATE KEY-----\nMIIEvgIBADAN...1oqO\n-----END PRIVATE KEY-----\n',
            Dialogflow_V2.LANG_ENGLISH_US,
            'testv2-3b5ca'
        );
    }

componentDidMount(){
  Dialogflow_V2.requestQuery("Some text for your Dialogflow agent", result=>console.log(result), error=>console.log(error));
}

error recieved:
{"error": {"code": 401, "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "status": "UNAUTHENTICATED"}}

@lewismclennan
Copy link

I've tried generating new service accounts and making sure the API is enabled on the project. Any idea what could be causing this?

@eniga
Copy link

eniga commented Jul 29, 2020

Sadly same issue here. Been stuck on this for over 2 weeks. Anyone got an alternative method?

@martinlockett
Copy link

This is how I do it:

const configureDialogFlow = (clientId: number | null) => {
  Dialogflow_V2.setConfiguration(
    env.DIALOGFLOW_CLIENT_EMAIL,
    env.DIALOGFLOW_PRIVATE_KEY,
    Dialogflow_V2.LANG_ENGLISH_GB,
    env.DIALOGFLOW_PROJECT_ID,
  );
  const permanentContexts = [
    {
      name: 'Auth',
      parameters: {
        lifespanCount: 100,
        AccessToken: clientId,
      },
    },
  ];
  Dialogflow_V2.setPermanentContexts(permanentContexts);
};

@RamithaSRavi
Copy link

Does anyone know a solution to this? The previous post requires TypeScript

@Jefferson-Lima-Santos
Copy link

Same here.

@shakshakeeb
Copy link

Hello, has anyone figured this out? I'm facing the same problem and have been stuck on this for weeks

@timkim0713
Copy link

I am using Expo and was having the same problem,

I checked my package.json, and it was using version "^3.1.0"
I changed to "3.1.1" and npm i and restarted.

Now, it works!

this is my onSend function


    const onSend = async (message) => {
        setMessages((previousMessages) => GiftedChat.append(previousMessages, message));
        let msg = message[0].text;

        try {
            const result = await new Promise((resolve, reject) => {
                Dialogflow_V2.requestQuery(
                    msg,
                    (result) => {
                        resolve(result);
                    },
                    (error) => {
                        reject(error);
                    }
                );
            });

            console.log(result);
            handleGoogleResponse(result.queryResult.fulfillmentText);
        } catch (error) {
            console.error(error);
        }
    };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants