0

I am unable to get the Agent User Id which is necessary to execute any request in the Google Home Graph API. The API is operated by a Service Account, however, the Scope for the Google Home Graph [https://www.googleapis.com/auth/homegraph] is not valid.

This scope cannot be authenticated anywhere, especially in the Google's OAuth Playground, from which you are supposed to get the Agent User Id for the requests.

How to get the Agent User Id and execute Home Graph requests if the Home Graph Scope in invalid and cannot be authenticated?

Or, how to authenticate the Google Home Graph Scope which currently displays an error saying it is not valid?

The Credentials are retrieved from the Service Account's JSON file this way:

string[] Scopes = { HomeGraphServiceService.ScopeConstants.Homegraph };
ServiceAccountCredential ServiceCred

        using (FileStream stream = new FileStream("MainCredentials.json", FileMode.Open, FileAccess.ReadWrite))
        {
            ServiceCred = ServiceAccountCredential.FromServiceAccountData(stream);
            GoogleCredential credentials = GoogleCredential.FromServiceAccountCredential(ServiceCred).CreateScoped(Scopes);

            var service = new HomeGraphServiceService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credentials,
                ApplicationName = "Test Application",
            });
        }

The only thing I am able to do now is to load the Service Account Credential JSON File to a GoogleCredential or ServiceAccountCredential, but I cannot do anything without the AgentUserId.

  • please edit your question and include your code. without seeing your code its very hard to help you . – Linda Lawton - DaImTo Feb 21 '21 at 12:59
  • What makes you think that api supports service accounts? – Linda Lawton - DaImTo Feb 21 '21 at 13:06
  • I've done much research and in the documentation it's said that that's the way to do it. (The request must be authorized by a service account) [Documentation](https://developers.google.com/assistant/smarthome/reference/rpc/google.home.graph.v1) – Techrex Studios Feb 21 '21 at 13:15
  • I'm not seeing anything about service accounts – Linda Lawton - DaImTo Feb 21 '21 at 15:08
  • Is says "This request must be authorized using service account credentials from your Actions console project." below the requests' names. Should I somehow link the project to an Action? It always asks for a Fulfillment URL, which I currently don't know how to get. – Techrex Studios Feb 21 '21 at 15:27

1 Answers1

0

You need to create a Smart Home Action in the Actions Console, where you provide your fulfillment URL.

You also need to provide your authorization and token URLs within the console as well, which need to match the endpoints you use to retrieve your AgentUserID through the OAuth Playground tool.

ToniCorinne
  • 503
  • 3
  • 12