question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to revoke access token in Action on Google SDK

See original GitHub issue

Hi, I want to revoke a token in a specific action returning a 401 error to the request (https://developers.google.com/actions/identity/oauth2-implicit-flow#revoke_tokens). I have not found how to do it with the “action-on-google” SDK and I have tried to do it by adding a middleware in my app, checking if the action of the request is the expected action and finally sending a response with status 401 and the payload JSON. My code:

const app = express();
const assistant = dialogflow();     // Integration with dialogflow
...
app.use((req, res, next) => {
	console.log('Middleware!');
	if(req.body.queryResult.action === EXPECTED_ACTION) {
		const response = {
			"payload": {
				"google": {
					"expectUserResponse": false,
					"richResponse": {
						"items": [
							{
								"simpleResponse": {
									"textToSpeech": "Good bye and have a nice day!"
								}
							}
						]
					},
					"userStorage": "{\"data\":{}}"
				}
			}
		};
		res.status(401).send(response);
		return;
	}
	next();
});

app.use(bodyParser.json(), assistant);

Doing the res.status(401).send(response); the Google Assistant revokes the token but the app crashes and it does not show the SimpleResponse. If I change the status to 200 (success) the Google Assistant shows the SimpleResponse but it does not revokes the token.

Is there any method in “actions-on-google-nodejs” SDK to revoke the token or send a 401 error with a message?

Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
florent33700commented, Jul 30, 2019

The UnauthorizedError exception does not seem to clear the access token anymore. However, It worked before.

3reactions
florent33700commented, Oct 4, 2018

I have the same problem, the application crashes when I return code 401. Would anyone have a solution to post a message before leaving?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Revoking ID tokens | Authentication - Google Developers
Users log in to their Google Account, find your app in the Third-party apps with account access settings and select Remove Access. ·...
Read more >
gcloud auth revoke | Google Cloud CLI Documentation
generate-login-token ... rolling-action ... gcloud auth revoke - revoke access credentials for an account. SYNOPSIS. gcloud auth revoke [ ACCOUNTS …] ...
Read more >
Actions on Google - How to revoke account linking?
Google exposes an API for revoking access and refresh tokens. ... https://accounts.google.com/o/oauth2/revoke?token={token} . See the different ...
Read more >
Revoke a Repository Access Token | Bitbucket Cloud
At bitbucket.org, navigate to the repository the Access Token was created for. On the sidebar, select Repository Settings. On the sidebar, under Security, ......
Read more >
Group access tokens - GitLab Docs
Revoke a group access token using the UI · On the top bar, select Main menu > Groups and find your group. ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found