I was reading your details and hoping that you may help me in my issue.
I have a google home at my home and some of the wifi bulbs & smoke sensor is connected to this, please note that i have not built these devices, i just bought them from market and just connected to the google home.
now I am creating a .net web application which can interact with google home to get the list of all devices with the status of the devices.
I have created a project in .net web application and trying to connect the google home via Google Graph API.
I have already done below steps:
I have created a project in https://console.cloud.google.com/ also have setup consent screen, also a service account with KEY and downloaded the the credential json file locally,
Setup scopes but it seems google graph scopes are not available at https://console.cloud.google.com/, so using smart management scops.
Using Oauth 2.0 at time of getting consent from user(in my case its me).
at the time of consent i am getting a code from google which i am using to get the access Token
CODE: ``` public async Task GetToken(string code) { var flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer { ClientSecrets = new ClientSecrets { ClientId = ClientId, ClientSecret = ClientSecret }, Scopes = Scopes, //Scopes = new[] { "https://www.googleapis.com/auth/sdm.service" }, DataStore = new FileDataStore("TokenFolder") });
var token = await flow.ExchangeCodeForTokenAsync("user", code, redirectUri, CancellationToken.None);
return token;
}
5. I am using below code to create Credentials from my service account file which were saved at credentialsPath:
``` GoogleCredential credential;
using (var stream = new FileStream(CredentialsPath, FileMode.Open, FileAccess.Read))
{
credential = GoogleCredential.FromStream(stream).CreateScoped(Scopes);
}
- I am using below code to create service instance by passing credentials.
{
HttpClientInitializer = credential,
ApplicationName = "Name of my application which i created in https://console.cloud.google.com/, "
});
I am now confused what to call from my service to get the list of all devices connected to google home. i tried to use intent types: SYNC, QUERY but it seems QUERY require AgentuserID which i am not sure what to pass?
NOTE: I have not created any ACTION in https://console.actions.google.com/ I was big confused while setting up Actions because it was asking me fulfilments url and other details which i am not aware of. as my application does not have any fulfillment endpoints.
It would be great help if someone can help on this matter. any video or any github code would really help.