Google action fulfillment url (with my own java server) - java

I'm trying to play with Google Home Action. I've created a new project, give it a name, then have to put a fulfillment url.
I've already implemented a small server (in Java, by using the class HttpsServer) to control a connected object in my house (it's already worked, I can send action to it by invoking a url, when I'm connected from my WIFI or outside of my home network with my 4G smartphone). The url is something like https://xxx.xxx.xxx.xxx:8080/my_object?action=test
So I've just tried to add a new "google" context to my server to do some "google action" when invoking via url https://xxx.xxx.xxx.xxx:8080/google. For now with this url, I just reply with a "OK google" string in a 200 answer and also display it locally on my console output. When invoking myself, it just display the string (by invoking it from my 4G connection).
Naively I think I just have to put my https://xxx.xxx.xxx.xxx:8080/google inside the fulfillment input box into the Google Action... and bim I will just have to understand the requests sent by Google (manage authentication, etc) to my tiny server. But when trying to invoke it via the simulator, my server is not triggered.
I must have missed something, but what?
If someone can help me, or put me to the correct direction, it would be great.
Regards

Just to resume:
Google Home Action accept only HTTPS fulfilement url.
And the https server must not use a self signed certificate.
Even with that, it never triger anything to my personal server (I've written to Google Support, answer me that tey will look... but after 1 week, problem is not solved).
My solution:
I just create an account on IFTTT, associate it to my google home account, and create a simple "applet" with if (select google assistant, input sentence I have to say), then (select webook, put the url of my server with the correct parameter in it)... save... it publish it to my google home assistant (how? I don't know and don't care)... try.. it works!
Don't know why Google do not provide something as simple as IFTTT to work with their assistant.

Related

App Links on Android with the app not installed

I am trying to implement app links into my app to make sure that other malicious apps cannot register for my URL.
I read the guide on app links here https://developer.android.com/training/app-links/verify-site-associations.html and I have mostly understood it. But one thing which is not clear to me is how can I prevent malicious apps from receiving my domain links if my app is not installed.
Consider this scenario.
1. My app is not installed on the user's device
2. Some malicious app is and it knows the URL that my app handles
Wouldn't this launch the malicious app and it can intercept my URL if the user selects that app from the disambiguation dialog? Is there any way to prevent it?
I understand that android:autoVerify="true" will trigger the domain verification when the app is installed, but what if the app is not installed?
Whether the user has the app installed or not, the "illegal" app won't be able to handle your links since it has not access to your domain in order to save there the needed JSON file. Am I clear?
There is a JSON file that is required during App Link configuration, that has to be uploaded to your server (that includes your app ID), through which your web-app basically says to the Android OS 'this is my counterpart on Android devices, I authorise it to handle these URLs'. Since app IDs are unique, there is no way another app can meet those conditions.
To quote the docs:
An Android App Link is a deep link based on your website URL that has
been verified to belong to your website.
So, although an app may register an <intent-filter> it ALSO has to be verified by the website whose URL it's trying to handle. And this happens on the server, so, out of the reach of a mobile client.
See also HERE for a more detailed explanation.

How do I callback to my own app from Spotify API?

I'm trying to connect to Spotify via API where I need a redirect_URI on a successfull callback. However, I'm new to this and don't really know what I should do here. I tried looking for ways on how to get the URI that refers to my app but I can't find anything. How do I get the URI that links to my app?
Redirect URL (go into your app’s settings and scroll down a bit and you’ll see an input field labeled Redirect URL. You’ll want to set this to an endpoint that your backend provides. Spotify is gonna send the user to this endpoint after the user has logged into Spotify successfully. Using a localhost URL will work if you're in dev mode.
The most apt information I found is :
https://medium.com/#stefmaxko/spotify-auth-flow-with-node-js-express-7ff13d72565a

YouTube Data API v3 quota exceeded on the first upload

I am trying to develop a desktop application in Java for uploading videos. I create a new Google account, create project on developer console and create credentials (ClientID and ClientSecret). After creating all of these, i do authorization (as in java examples), the application opens browser window for me to allow the application to manage the channel, and everything works fine.
But when i try to upload a video (short video, tried it on other channels before and it uploaded every time), i immediately get quota exceeded response. And in the developer console i can see that quota is actually exceeded (9644 queries already). I must add that this is happening only for the newly registered accounts - the same video uploads without issues using the same app.
Why is this happening? Is there any way I can "register" new account and immediately do upload? If not, how can I do this properly? Thanks
I had a similar problem with the python code that i used (i modified code based on https://developers.google.com/youtube/v3/guides/uploading_a_video). I solved it using the following workflow:
create a (new) google account if you dont have one yet
go to youtube, sign up with the google account and create a channel
go to
https://console.developers.google.com/apis/credentials?pli=1
create a project, pick a name
click on OAuth consent screen, pick external, pick application name
go back to Credentials, create Credentials using OAuthClient ID, pick Web application
pick a name, put into redirect urls: http://localhost:8080/ and https://developers.google.com/oauthplayground and save
go to Dashboard, search YouTube Data API v3 and enable
then go to https://developers.google.com/oauthplayground/
click on the rack wheel on the right, click use your own credentials, copy and past clientID and secret client from https://console.developers.google.com/apis/credentials and close
search for Youtube Data API v3 on the left, and select https://www.googleapis.com/auth/youtube.upload and https://www.googleapis.com/auth/youtube
click authorize APIs, log into your account, agree to all questions asked
Click Exchange authorization code for token
the Request on the right should not give you any errors
go back to https://console.developers.google.com/apis/credentials, when you click on the edit button next to your credentials, you should be able to download your JSON files. put them into the script folder under client_secrets.json
make sure to delete the file python_upload_video.py-oauth2.json from previous trys
when running the code with for example
python upload_video.py --file="input.mp4" --privacyStatus="unlisted"
the browser should open and ask you to log into your account
what i noticed is that:
if you get three errors in three hours it seems to exceed the quota and you cannot continue
the upload works for about 5 videos a day. If you need to upload more and cannot wait the only way is to create a new account and repeat the steps above (as far as I know)
It may be worth investigating further: I guess that your issue has to do with the API issues seen since about three days now. See the answer https://stackoverflow.com/a/55220182/8327971; also Google's known and acknowledged issue: https://issuetracker.google.com/issues/128673552.

Find out how app is pulling data from server so the same request can be done from webapp or other application

How can I find out exactly what type of request to a server is being made from an android app that I am using so I can replicate such a request outside of the app usage.
Specifically I am using the home depot app that has a bar code scanner.It also has a manual barcode number input.
The manual bar code input search is what I am interested in replicating for use in a webapp.
I assume it is just a server request with the appropriate information that the server responds to.
How might I start figuring this out?
You can use local proxy for your device. For example this one: http://www.charlesproxy.com

Writing a proxy for an android application

I have an android application which sends information to a server in particular it sends some stats to check the normal use that users do with the app. For example if they click a button to see a specific page a stat is sent to the server specifying a series of informations like the model of the phone, the page requested, the version of android ecc ecc. These informations are later visible using splunk http://www.splunk.com/. Now my problem is, for each event sent by my app, I should be able to say if the event was correclty sent to the server or not. My idea is to develop a proxy that can intercept the requests made by my app to the server and listen the response, like Charles proxy does. The problem is I don't know where to start. Anyone can suggest me how could accomplish this task? Thanks
Well I think you could add code to your application so that, when you send your data, you get the HTTP reply and check if code is 200 (Which stand for OK responde from server).
If so you know that your request went fine, if not(different reply code) you treat it as an error.
You will have to check if your server is responding properly, for an error and an OK message.
See also HTTP STATUS CODES
A good idea would be to use the Proxy Design Pattern for your extra code.

Categories