Adding feature to control users smart home devices using my app

29 Views Asked by At

I am working on an Android TV App project where I use OpenAI Assistant API to create a virtual assistant. Now I want to implement a feature in my app where the user can login with their google account and give my app to access their smart home devices connected to google. I have some done quick research and found bunch of documentation from google. Those are so much confusing. (Multiple SDK/APIs like Local Home SDK, Google Home Mobile SDK, Google Home Device SDK, Device Access, HomeGraph bla bla)...

I am getting confused which one to use.

I thought and got suggested by ChatGPT and Copilot that for my work Google Homegraph API should help me. But that's having an issue. When I try to login using Google in my app with Homegraph Scope permission, Google throws this error

Some requested scopes cannot be shown: [https://www.googleapis.com/auth/homegraph]

Note: I have enabled Homegraph API in Google Cloud Console and enabled the all scope for all the Smart Device Management API. (Couldn't find HomeGraph Scope there).

Now If I authenticate without the [https://www.googleapis.com/auth/homegraph] scope, then the homegraph api sends back some error for scope permission.

Now my question is, what API or library should I use in this case? If it is Homegraph API, then how can I enable the scope and continue.

Login activity function:

fun startLogin() {

    val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        .requestIdToken(getString(R.string.google_web_client_id))
        .requestProfile()
        .requestScopes(
            Scope("https://www.googleapis.com/auth/assistant-sdk-prototype"),
            Scope("https://www.googleapis.com/auth/homegraph")
        )
        .requestEmail()
        .build()

    googleSignInClient = GoogleSignIn.getClient(this, gso)
    val signInIntent = googleSignInClient?.signInIntent
    if (signInIntent != null) {
        launcher.launch(signInIntent)
    } else {
        Log.e("LoginFailure", "signInIntent is null")
    }
}
0

There are 0 best solutions below