Meteor App Login with iFrame



I am trying to integrate meteor app in an iframe and maintaining its session as well. Whenever user signin or sign out to my app, I am calling a method in meteor app to run login and logout script through postMessage call.

 ### script in my app ###

 var win = document.getElementById("meteor-app-iframe").contentWindow; 
 win.postMessage({'username': 'uname', 'password': 'pwd' }, 'meteor app url');
### script in meteor app  ###

function crossDomainLoginOut(event){
	if( &&{
		Meteor.loginWithPassword(,, function(error){
	} else if({

	addEventListener("message", crossDomainLoginOut, false);

One interesting thing that I encountered is that it works locally but after deploying it to staging it doesn’t work as expected. The logout works and login fails. Meteor.loginWithPassword("username","password") gets executed but it fails to login the user.

Any thoughts regarding this?

Thanks in advance.