Git Product home page Git Product logo

google-assistant-ruby's People

Contributors

akovtunov avatar armilam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-assistant-ruby's Issues

Get user id

According to the Google Actions documentation, you can get a user id that works similarly to a cookie session identifier. It's great for anonymous user identification. See the documentation.

Implement a way to get at this identifier.

This comes in the request JSON:

{
  "user": {
    "user_id": "abcd1234"
  },
  ...
}

Improve error handling

Right now, we handle_error(message) if something is wrong, and that just raises that message.

Instead, perhaps we should create error classes and raise instances of those instead?

Improve README

The README could use some better instruction and examples, as well as a copy of the license.

Request user information

According to Google's documentation, you can ask for user information, like their address. Implement a way to do this.

A possible API for this:

# lib/google_assistant/permission.rb
module GoogleAssistant
  module Permission
    NAME = "NAME"
    DEVICE_PRECISE_LOCATION = "DEVICE_PRECISE_LOCATION"
    DEVICE_COARSE_LOCATION = "DEVICE_COARSE_LOCATION"
  end
end

# controller
permission = GoogleAssistant::Permission::NAME
// OR
permission = [
  GoogleAssistant::Permission::NAME,
  GoogleAssistant::Permission::DEVICE_PRECISE_LOCATION
]
assistant.ask_for_permission("To address you by name and know where you sleep", permission)

And then, of course, we'll need a way to get that information from the response. It seems that information comes in the response immediately when the user allows it.

We'll also need to handle rejection.

Make GoogleAssistant a module

Right now, GoogleAssistant is a class and is also a namespace. I don't like this. Make it a module and move its direct functionality to another class.

Bad response from IdP in Auth Code Exchange

Hi, i'm currently trying to use rails to build custom google actions with DialogFlow, together with the omniauth-google_oauth2 gem to provide the oauth2 service. I also require user authorization in order to pull information from their google accounts.

All works well up till the point where the google user signs up/ chooses their google account. Right after they do so, an error occurs:

`{
"error": {
"code": 400,
"message": "Bad response from IdP in Auth Code Exchange",
"status": "FAILED_PRECONDITION"
}
}

Request URL: https://oauthintegrations.googleapis.com/v1/token:getForService
Request Method: POST
Status Code: 400
Remote Address: 74.125.24.95:443
Referrer Policy: no-referrer-when-downgrade
access-control-allow-origin: https://gala-demo.appspot.com
access-control-expose-headers: content-encoding,date,server,content-length
alt-svc: quic=":443"; ma=2592000; v="43,42,41,39,35"
cache-control: private
content-encoding: gzip
content-length: 136
content-type: application/json; charset=UTF-8
date: Thu, 05 Jul 2018 13:17:41 GMT
server: ESF
status: 400
vary: Origin, X-Origin, Referer
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
Provisional headers are shown
Authorization: Bearer *my access_token*
Content-Type: application/json
Origin: https://gala-demo.appspot.com
Referer: https://gala-demo.appspot.com/app
User-Agent: *my user agent*
{credential: {,…}, gdiState: "APP_AUTH", serviceId: "ardent-fusion-209108_dev",…}
credential
:
{,…}
gdiState
:
"APP_AUTH"
scopes
:
["https://mail.google.com/"]
serviceId
:
"*my_project_id*_dev"`

On Actions on Google, I've set the account linking settings to be:

  1. Set the linking type to be only Oauth, and grant type to be implicit.
  2. Set the Client ID as my oauth2 client ID
  3. Authorization URL as my-app.com/users/auth/google_oauth2
  4. Set scope as 'https://mail.google.com/'
  5. Set testing information as 'username: [email protected], password: password'. I do not know what is the proper format for this field yet.

On DialogFlow, I've also set the webhooks to be that of my_rails_app.com/google_assistant, without any headers/username and password as i have already put skip_before_verify for my google assistant action.

(I've also tried setting the linking flow to be the authorization code flow. However, i am unsure what is the token_url, and when i put in the same url as that of the auth url, the same error occurs.)

Please do let me know if there is any more information you need! I've already asked the same question on Stackoverflow here: https://stackoverflow.com/questions/51178237/bad-response-from-idp-in-auth-code-exchange-during-google-account-linking-with-r , and the very helpful user Prisoner has helped me clarify that this may be an issue with omniauth (if you feel the same way, let me know and i'll re-open the issue at the omniauth gem page instead). He also mentioned it may only work with the authorization code flow, but i've tried that way to no avail as well.

EDIT: I've since realized that omniauth follows the auth code flow. I've thus changed my linking flow to auth code and added /users/auth/google_oauth2 as my auth url and /users/auth/google_oauth2/callback as my token url. However, there is now an error of redirect_uri_mismatch even though i have added https://my_app.com//users/auth/google_oauth2/callback and https://my_app.com//users/auth/google_oauth2 into my oauth client's authorized uri redirects.

Any help will be greatly appreciated!

Support surface capabilities

Google API requests come in with a list of the device's capabilities:

"surface": {
    "capabilities": [
        {
            "name": "actions.capability.AUDIO_OUTPUT"
        },
        {
            "name": "actions.capability.SCREEN_OUTPUT"
        }
    ]
}

Add support for reading that.

Improve API of build_input_prompt

GooglAssistant#build_input_prompt is based off Google's node SDK, but I think we can improve on the API for ruby. Explore some options and change the API to make it more intuitive and ruby-like.

Add RDocs

It would be nice to document the code itself now that it's taking shape.

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.