How to stay inside outlook Add-in when authenticating

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

How to stay inside outlook Add-in when authenticating

Postby swingman » Wed Jan 11, 2023 11:53 pm

Hi all,

now another interesting problem, Servoy is running inside an iFrame in Microsoft Outlook and I want to Authenticate against Azure AD.
Code: Select all
function authorize() {
   var service = plugins.oauth.getOAuthService(plugins.oauth.OAuthProviders.MICROSOFT_AD, clientId, clientSecret, 'User.read', state, callback);
   application.showURL(service.getAuthorizationURL());
}

function microsoft_ad_callback(a,args) {
   var service = plugins.oauth.getOAuthService(plugins.oauth.OAuthProviders.MICROSOFT_AD, clientId, clientSecret, 'User.read', state, callback);
   service.setAccessToken(args.code);
   /** @type {plugins.oauth.OAuthResponseJSON} */
   var response = service.executeGetRequest("https://graph.microsoft.com/v1.0/me");
   if (response.getCode() == 200) {
      var json = response.getAsJSON();
                //more code here
        } else {
                //failed
        }
}


Now, application.showURL, simply adds another tab to my web browser, displays the authentication dialog from Microsoft. If I authenticate, I end up with a normal Servoy running in my browser.
I want to stay within Microsoft Outlook, how can I show the service.getAuthorizationURL() so I can authenticate?
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1479
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Re: How to stay inside outlook Add-in when authenticating

Postby emera » Thu Jan 12, 2023 11:05 am

You need to use
application.showURL(service.getAuthorizationURL(), "_self");
because application.showURL(service.getAuthorizationURL()) shows it by default in a new tab.
emera
 
Posts: 44
Joined: Tue Jun 17, 2014 8:33 am

Re: How to stay inside outlook Add-in when authenticating

Postby swingman » Thu Jan 12, 2023 1:46 pm

Hi, I tried that but I still ended up in the default browser.
After a rethink, I have decided as the user is already logged into their computer and email, I can trust Microsoft to tell me who the user is and check if the user has an account which is not disabled on Servoy and simply let them in.
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1479
Joined: Wed Oct 01, 2003 10:20 am
Location: London


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: No registered users and 32 guests

cron