in tnis auth sample of google-oauth, how can I get callback of closing browser? - google-api

Using this sample api named 'Auth.java',
https://github.com/youtube/api-samples/tree/master/java/src/main/java/com/google/api/services/samples/youtube/cmdline
last of those line :
'return new AuthorizationCodeInstalledApp(flow, localReceiver).authorize("user");'
when that .authorize("user") start to work, it opens google account select page on default brower .
if I choose my google account and following flows, it works very well.
but problem occured after opening browser. if I don't choose google account or just close this page, code stopped and stay that line. so close browser and if I take course of Oauth again, error
occurs : binding port already used(8080).
what I want is how can I take callback from server or anywhere like browser has closed so rollback this process or if authorizing process doesn't work for miinute, process roll back.

Related

How to solve a sudden ssl_cacert error of Slack app that has been running flawlessly?

I've had a Slack app up and running for quite some time which has been working flawlessly. The app sends messages that have an interactive button on it. It also has slash command interactivity.
However, since this morning, whenever a user presses the button on the message, Slack displays an exclamation point (!) next to it with the message "Error in establishing a secure connection. Please use a secure certificate for the interactivity URL of this app."
The SSL cert on my server is not expired and I've made absolutely no changes to the Request URL within the app's settings. Does anyone know what the problem may be?

Close Extension window automatically after sending transaction

When you use the Maiar Exchange with the Chrome Extension and send a transaction, you can see that the extension window automatically closes after sending the transaction.
When I implement the same behavior, the Extension window stays open and the sendTransaction() Promise only resolves after the call is done. If I close the window by myself by clicking somewhere else on the website, I get the following error in the console:
Uncaught (in promise) Extension window was closed without response.
With that error, my promise success resolving code is not executed anymore which basically forces the user to wait about 30 seconds until the transaction is done.
This happens when using the sendTransaction() method of the ExtensionProvider from erdjs.
Does anyone have an explanation how e.g. the Maiar Exchange solves this?
The way the Maiar Exchange handles this is slightly different from your approach.
Sending the transaction directly with the ExtensionProvider requires that the extension window stays open until it is finished to return you the result.
However if you only use the ExtensionProvider to sign the transaction using the signTransaction method and send it yourself via the ProxyProvider you won't run into this limitation. The signing is basically instant and quickly closes the extension window. It also allows you to retry sending, without user interaction, if you run into any timeouts or similar.

Custom google home action should always reconnect to get it working

i have a custom google home action implemented as described in the documentation (Oauth2 setup, sync, execute, etc... setup) and all works as expected on my Google home app and my google home physical devices.
Now, every now and then i need to reconnect the app in the Google Home App because it seems the app cannot reach my devices after some time. I checked my Oauth server if the refresh tokens are working ok and they do. Also my access token expires after 20 minutes and me reconnecting to the app should be done after some hours so the refreshing works in my opinion.
Now, are there any restrictions in using the TEST of the google home action?
The case i wrote is specific for personal use (intergration with personal server and domotica system) so i am actually not planning on releasing it, I just want to use it for myself. Is this allowed? Can i just leave my action in 'test' forever for such purposes?
EDIT: 18/05/2022: custom actions still working flawlessly after 6 months in test :-)
EDIT: 02/02/2023: custom actions still working flawlessly in test :-)
Additional question:
If i have to submit the app for release, i cannot meet the expectation in implementing state report as i have no control over the usage of buttons pressed at my home domotica. Is State Reporting also accepted when i report the state of my devices over time (let's say, every hour?)
tnx
EDIT:
So it seems there is something wrong with my refreshing of the tokens but i don't know what. When i try through postman, all works as expected, in stackdriver logs i see this :
jsonPayload: {
#type: "type.googleapis.com/google.identity.accountlinking.type.AccountLinkingError"
errorReason: "Failed to get response from 3P. 3P returned malformed response like invalid response code or un-inflatble body."
request: {
body: "grant_type=refresh_token&refresh_token=REDACTED_VALUE&client_id=qbusauth&client_secret=REDACTED_VALUE"
method: "POST"
uri: "https://******.azurewebsites.net/token"
}
sessionId: -1039956344
step: "REFRESH_ACCESS_TOKEN"
If you don't plan to submit your Action for release, you'll just need to occasionally re-enable device testing through the console.
To minimize the number of query intents to your fulfillment, you should implement Report State and proactively send device states to update HomeGraph. You would have to implement this if you decide to release your Action.

How does one github tab knows when I logged out on another

To replicate:
Open two github tabs on which you're both logged in
Log out of one tab.
At the top of the 2nd tab you almost immediately get notification that you logged out on another tab
I've been trying to figure out how this works. Since the notification is almost immediate I considered 3 possibilities:
Each tab makes XHR/AJAX requests on a schedule to check session validity with the server (or uses long polling)
Each tab registers an event listener to Server Sent Events, and receives notification from the server upon logout.
Each tab has a websocket connection to the server, and receives a similar notification.
For reference, these technologies are discussed here. I am stumped though because when I open the web browser's (Firefox 48 beta) network requests dev tool, I see no communication on the tab that shows the notification between the time I log out of the other tab, and the time the notification appears.
By the way, the notification works in the opposite direction as well. If you have two tabs logged out, and you log into one of them, a notification immediately pops up on the other tab that you logged in. What's going on?
Github uses Local Storage for this trick. It uses entry with key 'logged-in'. This key is either true or false and is set each time user logs in/out. Each tab constantly check (as I know there is no event on Local Storage modification) Local Storage.

FacebookOAuthException: Error validating access token on WP7 using Facebook C# SDK

I have a strange problem with the Facebook C# SDK on Windows Phone 7. I am using the SDK to post pictures to users' walls. For the first authentication and the first few posts, it works great. After a while (I have a feeling the magic cutoff is 24hrs) I start to get an error on every post:
FacebookOAuthException was unhandled
(OAuthException) Error validating access token.
This happens after my line of code that does the actual post has run...
m_facebook.PostAsync(#"/photos", parameters, PostComplete);
... but before my PostComplete callback function is called. No code of mine is running when the exception happens. My Application_UnhandledException is not called - I get the error in a dialog in the middle of the screen in VS, and it says that no source code is available.
If this exception means I need to show the login screen again, that's fine - right now I'm both not sure what it means and not sure how to trap the bugger. Any help appreciated.
Chris
What publishing permissions do you use?
By default, access tokens expire after a short time period to ensure applications only make requests on behalf of the user when the are actively using the application.
For getting a long-lived access token, you need to ask for the offline_access permission.

Resources