Reputation: 509
I'm developing an outlook addin. It is JS based, which uses OAuth2 to authenticate users. I'm using poupp window to open authorization page like google, azure ... and after success login I close it. To go back into application I'm registering a callback function on parent window of popup which is accessible via window.opener
property. Everything is working fine, however I would like to support mobile devices.
To run that kind of addin is possible via OWA for Devices app, which could be downloaded via Play Store.
Problem is that window.opener
property is always null. So I can't call back into application.
Is there any other way how to call back into application? How to access the parent window of the popup?
Upvotes: 0
Views: 874
Reputation: 4521
The correct way of solving that problem is through WebSockets. You can make sure that you're posting the credentials to a single client. In your web addin, start a socket
Add-In - Client Javascript should look like:
var socket = io('http://localhost');
var email = Office.context.mailbox.userProfile.email;
socket.on('oauth_providerName_'+email, function(data){
// Callback when you receive the credential data.
});
// Pop the user to the OAuth frame
Once the user is redirected from the OAuth experience back to your website,
Website - Client Javascript
var socket = io('http://localhost');
var email = Office.context.mailbox.userProfile.email;
socket.emit('oauth_cred_providerName_'+email, {credentials});
Server - depending on your chosen language, you pass the credential data through sockets to the Add-In client.
So ideally you have 3 components here:
Upvotes: 1