Code Monkey home page Code Monkey logo

device-access-sample-web-app's Introduction

Device Access Web Application Sample

Device Access Logo

Device Access enables access, control, and management of Nest devices within partner apps, solutions, and smart home ecosystems, using the Smart Device Management (SDM) API.

Developers can use the code in this repository with the directions provided below to deploy a functioning web application to control Nest cameras, doorbells, and thermostats.

If you are new to Device Access, we recommend you to start with the Building a Device Access Web Application Codelab.

Deploying the Sample App

After creating a project on Firebase, use the steps below to deploy the sample app.

Clone the sample app:

git clone https://github.com/google/device-access-sample-web-app.git

Navigate into project directory:

cd device-access-sample-web-app

Link the app with your Firebase project:

firebase use --add [PROJECT-ID]

Deploy the app to your Firebase project:

firebase deploy

You can then access the app at your Hosting URL (https://[PROJECT-ID].web.app).

Using the Sample App

Enter the OAuth credentials you created on Google Cloud Platform, as well as the Project Id from Device Access Console to complete the account linking flow for a Google account with a linked Nest device.

Make sure to add the redirect url [PROJECT-ID].web.app/auth in list of authorized URLs for your Client Id on Google Cloud Platform to prevent Error 400: redirect_url_mismatch. More instructions on this can be found at Handling OAuth section from the Building a Device Access Web Application Codelab.

You can try out a live demo at device-access-sample.web.app.

device-access-sample-web-app's People

Contributors

hemslo avatar jtromo avatar vyrastas avatar yigituyan 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

Watchers

 avatar  avatar  avatar

device-access-sample-web-app's Issues

Not Receiving Access token anymore

Yesterday, I set up the sample app and got everything to work with the auth and was able to sign into the app, but camera streaming wasn't working. The log just outputs "Initiating Camera Stream call to Device Access API". Now today the I'm not receiving an access token and the logs are outputting:
{ "error": "invalid_grant", "error_description": "Bad Request" }

I've tried changing out the oauth client id, changing the project on device access console, and still getting the same response.

Does anybody have a solution for this?

Error 404 Not Found

When trying to sign the project with the correct oauth credentials I receive a 404 error with this message: The requested URL was not found on this server. That’s all we know.

Refresh Stream button returns 400 status code for Nest camera

Overview

The Refresh Stream button in the live demo and local instances of this app are returning 400 errors.

Repro

  1. Setup the app and device management per instructions, enable permission to a Google Nest camera (v2 wired).
  2. Login using ID, Secret, Project ID as mentioned in the project
  3. Click Camera Stream and you will successfully get a live stream!
  4. Now click Refresh Stream and you will get the following 400 status code:

Post Response

{
  "error": {
    "code": 400,
    "message": "WebRtc error caused by invalid session or user id mismatch.",
    "status": "FAILED_PRECONDITION"
  }
}

Potential cause

In looking at the Post Request log, I see the Payload params has an empty mediaSessionId as you can see in the Request snippet:

Post Request - Note: I removed the endpoint and auth bearer token

/// Endpoint ...
/// Authorization ..
Payload: 
{
    "command": "sdm.devices.commands.CameraLiveStream.ExtendWebRtcStream",
    "params": {
        "mediaSessionId": ""
    }
}

Not working on firefox

On firefox, when the stream starts, i receive the error:
Failed to create session description: InvalidAccessError: Answer tried to set recv when offer did not set send.

I'm on Firefox 116.0.2

Error: malformed auth code

The request to get an auth code fails with the error:

{ "error": "invalid_grant", "error_description": "Malformed auth code." }

Posts on Stack overflow suggests that the code needs to be url decoded before being sent. And yes, sure enough.. I can see in the request part, that the code contain %2F which should be converted to /.

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.