Closed isabelle112 closed 7 years ago
@isabelle112 AAD does not allow query string parameters or hashes in the reply urls. Do you want the token to be returned to a url something like this: https://isabelle.company/wp-admin/admin.php?page=dyn-crm-login#id_token=eqwewqde...?
Unfortunately, that is not allowed by AAD. But adal saves the current page before it redirects the user to the AAD login screen. Once login process is completed, adal redirects the user back to this page.
If you want to redirect the user to a certain location after login process is completed, you can use adal.config.callback property. This callback will be called once login is completed and you can redirect the user to the page you want. Also, you might need to change your code to execute adal.js when https://isabelle.company/wp-admin/admin.php is loaded in order to process the token.
Few questions:
AAD does not allow use of querystring parameters and hashes in the redirect uri. And that's AAD will not send back the token to url with QSP/hashes.
Hey all,
my task is to build a wordpress plugin with the functionality to login to dynamics crm and get information out of dynamics crm to wordpress. I use the adal.js code for the authentication. I am working on this project for 4 weeks now and i got stuck on an issue for which I can't find a solution.
The situation is that I have created a wordpress admin menu item. On the submenu page I have my .php code. I want to receive the information after logging in on this wordpress page. Well the URL of the wordpress page is similar to this: https://isabelle.company/wp-admin/admin.php?page=dyn-crm-login. On this page my javascript code and the adal.js is loaded. I've posted the code. Everything works fine till the token is sent back to my wordpress page. The querystring is cut off and my authContext is undefined. It seems like the whole information is lost. And the token is attachted to my site url, but without the querystring. I know that adal.js doesn't accept a querystring - but I need a solution and I am sure there must be one. I tried to do the connection on a seperate .php file, but it doesn't work either, If I work on a developement environment (I used cloud9 if anybody knows that), the code works perfectly, but if I sent some information to the javascript file and store them in a variable inside the javascript file it doesn't work either. It's really weird, because I get my fullname displayed on the page for a few seconds, then the page loads further and everything is destroyed, the object is undefined, my name is gone and the information I had sent to the javascript file and stored in the variables are gone. It's kind of a page refresh which destroyes everything. I am trying to solve that problem since 2 weeks, I read the whole adal.js code and tried a lot of different ideas, but nothing worked. I hope anybody has a solution.
Could anyone help me out please?
Please excuse my english - it's not my mother tongue.
You can find my Javascript code inside the attached file. my_script.zip
My (relevant) code on the Admin Page:
echo '<h1>CRM to Wordpress Connection</h1>'; echo '<p>You will send up automatically to the login page of Microsoft Dynamics CRM</p>'; echo '<div id="anonymous_user">'; echo '<button id="logincrm" onclick="connect()">LogIn</button>'; echo '</div>'; echo '<div id="register_user">'; echo '<a id="user_name"></a>'; echo '<button type="button" id="sign_out">Sign out</button>'; echo '</div>'; echo '<button class="btn btn-primary" id="btn_get_name">Get the full name</button>';
Thanks! :)