Meteor JS - Receiving Code in Redirect URI with Iron Router


#1

Presently I am trying to build an OAuth handler for a specific service.

After authorizing my client application, I receive a redirect URI (which I specify) along with an authorization code at the end of it. Such as:

http://localhost:3000/test/?code=gJS%2Bh%2BN9pSqB%2FAsoM1QOMCelvw

I have in my Meteor Client

Router.route('/test/:_id', function(){
	var params = this.params;
	var code = params._id;
	console.log(code);
	this.render('testRoute');
});

Which follows the documentation provided at…

I receive the error message in browser "Oops, looks like there’s no route on the client or the server for url: ‘http://localhost:3000/test/?code=gJS%2Bh%2BN9pSqB%2FAsoM1QOMCelvw’. "

And it appears to never execute that block of code.

When I remove, the “:_id”, it routes properly but cannot handle the route parameter, coming back as “undefined”. Does anyone have any idea why this is happening?


#2

I cant delete my original but I figured out my problem…

This is not considered an “id” but instead is a “QUERY_STRING”, which can be accessed using
var code = this.params.query;
instead of
var code = this.params._id;

and the correct router code is…

Router.route('/test/:_id', function(){
var code = this.params._id;
console.log(code);
this.render('testRoute');
});

Just in case anybody else ever needs it…