Git Product home page Git Product logo

Comments (5)

m90 avatar m90 commented on June 3, 2024 12

@taeminpark thanks! I actually ended up doing it quite similarly, but without reading the file myself:

from google.oauth2.service_account import Credentials
credentials = Credentials.from_service_account_file('<service_account_json>')
session_client = dialogflow_v2.SessionsClient(credentials=credentials)

from python-dialogflow.

taempark avatar taempark commented on June 3, 2024 4

Yes. you can use like this:

from google.oauth2 import service_account
dialogflow_key = json.load(open('<service_account_path.json>'))
credentials = (service_account.Credentials.from_service_account_info(dialogflow_key))
session_client = dialogflow_v2.SessionsClient(credentials=credentials)

from python-dialogflow.

taempark avatar taempark commented on June 3, 2024

Nice! I also have to raise an issue but it seems to DialogFlow team is not reading issues...

from python-dialogflow.

crwilcox avatar crwilcox commented on June 3, 2024

The comment above specifies the correct way to do this #71 (comment)

from python-dialogflow.

aaronamelgar avatar aaronamelgar commented on June 3, 2024

How do we do this without storing private key JSON on the repo?

In the node package we can do something like this, but I haven't been able to do this.

class DialogFlow {
constructor (projectId) {
this.projectId = projectId
let privateKey = (process.env.NODE_ENV=="production") ? JSON.parse(process.env.DIALOGFLOW_PRIVATE_KEY) : process.env.DIALOGFLOW_PRIVATE_KEY
let clientEmail = process.env.DIALOGFLOW_CLIENT_EMAIL
let config = {
credentials: {
private_key: privateKey,
client_email: clientEmail
}
}
this.sessionClient = new dialogflow.SessionsClient(config)
}

This is the code I tried but the formatting is not correct because I am getting errors

key = os.environ.get('DF_PRIVATE_KEY')
key = key.split("\n")
del key[-1]
del key[0]
df_key = "".join(key) #cleans private key from /n
config = {credentials : {'private_key'=df_key, 'client_email': os.environ.get('DF_CLIENT_EMAIL')}}
session_client = dialogflow.SessionsClient(config)

from python-dialogflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.