-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iframe Login Issue not Loading anything #7545
Comments
Resolved. Thank you for this great product!! |
@stacybot123 How did u resolved? Why don't you post your solution? It might be helpful for somebody. |
@albanafmeti Sorry , I didn't posted the solution. The documentation on the website needs to be a bit clear. It needs three files. What I was doing was I created two files one main and the other to get the login token. Here is a good tutorial for this. http://webdevllc.biz/index.php?/blog/2016/12/how-to-iframe-rocket-chat |
@albanafmeti I again have a new issue is how I can use two domains for same same instance of rocket chat while using iframe login |
@stacybot123 Can you provide your solution to us?? we still have problem about Iframe login... |
@defend0827 You need to create three files. One which will have the iframe. Second which you will enter in the "Iframe Url" and third to be updated on API URL. Let is suppose you have rocketchat installed on www.mychatrocket.com Creating Files: #1 : This will be the actutal URL where you have to Show Chat. Let us name the file as chat.php. So my url will be www.mydashboard.com/chat.php Below is the code on Chat.php <iframe src="www.mychatrocket.com/home" name="myframe" style="width: 100vw;height: 100vh;position: relative; overflow-y: hidden; display:block; line-height: 0;" id="myframe" frameBorder="0" scrolling="no"></iframe>#2. The second file will be the one you need to update on RocketChat " Iframe Url " on your Chat installation: Let us suppose the name of the file is get_user_token.php. So the url you will update on " Iframe Url " will be www.mydashboard.com/get_user_token.php Now based on the session of the user retrieve the username and password for the user and make a call to your /api/v1/login endpoint. In our Example it will be www.mychatrocket.com/api/v1/login to get the token // login known rocket.chat user using REST API $data = array ( $dats = json_encode($data); curl_setopt($ch, CURLOPT_URL,"http://www.mychatrocket.com/api/v1/login"); $authtok = $json->data->authToken; $sql ="Update chat_users set chat_token= '". $authtok ."' WHERE user='example_session_user'"; #3. Now the Next file will be one you need to update in "API URL" on rocketchat installation. This will return the token you have generated in the previous call/file Again based on the session of the user return the token. The code will be . $sql ="SELECT chat_token FROM chat_users WHERE chat_users ='example_session_user'"; echo '{ "loginToken":"'. $token .'"}'; Thats it. You will be able to load RocketChat. Let me know if you need help. Everytime Rocketchat will load on any url, we need to generate and return the token. The problem starts when we start trying it to load it on the url we provided in "iframe URL" |
@stacybot123 Thanks for your assis it's working now, Thanks again. |
Hi @stacybot123 I am trying to integrated the rocket chat in ionic app. And I am able to generate token according to your #2 setp and stored that token as Local storage to my app. But while in #3 step I have a web service which need to return the token which we already generated in step #2 as you said. So as you used table chat_token $sql ="SELECT chat_token FROM chat_users WHERE chat_users ='example_session_user'"; Here I did not find any tables in rocket chat db, which store the token which we generate in step #216 I am using rest services for step #1 and #2 and #3 as well. Please assist me Its urgent for me. I will be great-full to you. Step #1: <iframe src="http://192.168.10.137:3000/home" name="myframe" style="width: 100vw;height: 100vh;position: relative; overflow-y: hidden; display:block; line-height: 0;" id="myframe" frameBorder="0" scrolling="no"></iframe>Step #2: http://192.168.10.137:8080/api/get_user_token And the loginToken return from. http://192.168.10.137:3000/api/v1/login and I have stored this token to local storage.As sessionService.store('loginToken', response.data.rocketChatAuthToken); Now in step #3 According to your point we need to return the token again which is generated in #2 Here can you please assist me I am confuse here. I have rocket chat db but there I did not find any table as you said in step #3 Thanks in advance.. |
I have also implemented it in Ionicv1. Thanks all |
there is a proper doc page explaining how that works https://rocket.chat/docs/developer-guides/iframe-integration/authentication/ |
I guess this is not the final solution, cause after you set the IFrame URL and API URL, you will not be able to access your RC deployed site :(. Adding to that, this will limit access to a single user, cause your web site will just call the IFrame URL and API URL without being able to specify the user. I spent a very good time to integrate RC IFrame within my web application, with no luck, then I have reached the solution, which is not documented very well by RC :(. This is my solution where you can have IFrame within your website by dynamically specifying the channel and user dynamically:
I hope this would help someone :). |
can you suggest if you had to do extra settings to make ifame integration work. I am using |
Description:
I am trying to login to Iframe using the token. I generated the token at the login page using the username and password. Now on the page where I am trying to load the instance nothing is loading . I am not getting any error message on the Console.
The Rocket Chat is installed on Google Cloud Server.
The Dashboard where I want to Show Chat is on Other server
Here is the code I used to generate the token :
curl_setopt($ch, CURLOPT_URL,"http://myserverurl/api/v1/login");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $dats);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
)
);
$server_output = curl_exec ($ch);
curl_close ($ch);
$json = json_decode($server_output);
$authtok = $json->data->authToken;
Here is the Chat page where I need to show the rocket chat. Below is the JS code :
$(document).ready(function(){
var y = document.getElementById("myframe");
y.contentWindow.postMessage({
externalCommand: 'login-with-token',
token: 'fChpekpRjHrY3cGAp7D3XLxMBFSCDkzOuJVNeJJRKBR'
}, "*")
});
Here is the HTML body with the iframe and src
<iframe src="http://myserverurl/home" name="myframe" style="width:100%;" id="myframe"></iframe>Server Setup Information:
Steps to Reproduce:
Expected behavior:
Should have loaded the Rocket Chat
Actual behavior:
Not loading anything on the page
Relevant logs:
Whenever I generate a token I have this Logs on server : [Method] registerLoginHandler
Log on Browser. I do not have any error
The text was updated successfully, but these errors were encountered: