How do you call an Azure function using authentication from an O365 Nintex Form

  • 24 September 2019
  • 4 replies
  • 18 views

Badge +1

I am trying to call an Azure Function authenticated via AAD from a Nintex Form via javascript. I have code to call an Azure Function via an API Key but would prefer to use the User's credentials. I have looked at adal.js and msal.js. I have gotten very close to getting it working, but have run into a brick wall in each case.

For adal.js, the authentication tries to use an iframe from the Nintex form. This resulted in:

'https://login.microsoftonline.com/common/oauth2/authorize?client_id=<removed>&response_type=token&redirect_uri=<removed>&resource=https%3A%2F%2Fgraph.microsoft.com' in a frame because it set 'X-Frame-Options' to 'deny'.

 

Something similar happened with msal.js when using silent authentication.

 

Has anyone tried to do this yet? Any help would be greatly appreciated.


4 replies

Badge +17

Unfortunately, this is a very specific need. Javascript in Classic form may be your best bet. Why are you attempting to call an Azure function from a form?

Userlevel 2
Badge +5

It would be nice to have secure communications to Azure from the form. I can see many uses for this.

Badge +1

I have code to be able to call an Azure function from a Nintex form using an API key. This was done using Javascript in a Classic form. Unfortunately, this exposes the API key in the javascript.


 


It would be great to be able to use the credentials of the user logged into SharePoint to authenticate their access to the Azure function. The adal.js and msal.js libraries that Microsoft has put out were made for this type of thing.


 


The Azure function implements some business logic such as retrieving data from a backend SQL db based on information entered into the form, or returning members of an AAD Group for a drop down, or getting purchase authorization amounts based on user, etc.

Hi,


I've the same problem, when I try to call an Azure Function authenticated with Azure AD from JQuery in a classic Nintex Form. Do you have any updates in how to send the credentials logged into SharePoint in the request?


I've CORS enabled and configured with Nintex Tenant, but when I try to call the Azure Function and send the credentials, it redirects to https://login.windows.net and throw an error:


 


Access to XMLHttpRequest at 'https://login.windows.net/...' (redirected from 'https://...) from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.


 


Thanks!

Reply