azure
5 TopicsAzure Function and SharePoint PnP PowerShell are mixing up the client context
Hi, I'm experimenting with Azure Function, Logic apps/Flow to replace an existing SharePoint Workflow. I've found a weird issue where the client context get mixed up when multiple flows are running in parallel and try to call the azure function. I've found a workaround to overcome this issue by allowing only one job on the azure function environment. It's not a good solution, therefor I want to find the root cause of the following error message : Exception calling "Load" with "1" argument(s): "The object is used in the context different from the one associated with the object." Has someone encounter a similar issue? Cheers Bernd2.4KViews1like3Comments401 Error using PnP PowerShell in Azure Runbooks
Trying to get PnP PowerShell cmdlets to work within an Azure Runbook with modern authentication (no username/password). I tried registering an Azure AD app and a Service Principal (Run as account) from the automation account that hosts the Runbook. Both use a certificate thumbprint and authorization itself doesn't throw an error. Here's the code I'm using: $connection = Get-AutomationConnection –Name "AzureRunAsConnection" $tenant = '[tenant].onmicrosoft.com' $url = 'https://[tenant].sharepoint.com/sites/test' Connect-PnPOnline -Url $url –Thumbprint $connection.CertificateThumbprint –ClientId $connection.ApplicationID -Tenant $tenant For every PnP cmdlet this throws the following error. Get-PnPTenantSite : The remote server returned an error: (401) Unauthorized. At line:7 char:1 + Get-PnPTenantSite + ~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-PnPTenantSite], WebException + FullyQualifiedErrorId : System.Net.WebException,PnP.PowerShell.Commands.GetTenantSite I have also updated the cmdlets from SharePointPnPPowerShellOnline to the newest PnP.PowerShell. Furthermore, the Azure app and service principal are members of the SharePoint administrators group. When I attempt to reproduce the issue on a local machine I get the same 401 error. Any ideas? Thanks!Solved7.5KViews0likes3CommentsHow can I auto-logged an user inside a Sharepoint Web Part?
I have a website "Play web". When I want to access into this site I have to login previously with user/pass. An authtentication module, handle this info and starts a communication with an Azure AD. If the user is validated properly using a callback the control is returned to the Play Web with the user logged. All these steps works fine. Where is the problem?. One of our clients wants to embed this "Play web" inside his Sharepoint but he doesn't want relogin. He needs to use the Sharepoint context to autologged the user into the website. Is there any way to do this?, Should have I setup something in Azure AD: Proxy, Function? I'm stuck with this. RegardsSolved4KViews0likes3CommentsHow to get an accessToken using MSAL library inside a Sharepoint Web Part?
I have developed a Sharepoint Web Part where I need to obtain the accessToken. To obtain the token I have used a MSAL library. My problem is the next one: I'm logged in my Sharepoint but when the Web Part try to retrieve the accessToken something fails in the authentication and appears this error: xxxx-web-part.js:1838 ClientAuthError: User login is required. at ClientAuthError.AuthError [as constructor] (https://localhost:4321/dist/xxx-web-part.js:2057:28) at new ClientAuthError (https://localhost:4321/dist/xxxx-web-part.js:630:28) at Function.7ZR7.ClientAuthError.createUserLoginRequiredError (https://localhost:4321/dist/xxxx-web-part.js:682:16) at https://localhost:4321/dist/xxx-web-part.js:2916:103 at new Promise () at UserAgentApplication.ZES5.UserAgentApplication.acquireTokenSilent (https://localhost:4321/dist/xxxx-web-part.js:2905:16) at UserAgentApplication.descriptor.value [as acquireTokenSilent] (https://localhost:4321/dist/xxxx-web-part.js:2543:38) at xxxWebPart.PlTk.xxxxWebPart.render (https://localhost:4321/dist/xxxx-web-part.js:1828:19) at xxxxWebPart.t._renderWithAccessibleTitle (https://spoprod-a.akamaihd.net/files/sp-client/sp-webpart-workbench-assembly_en-us_27e01b6941bf5cdddecc695bd3bdbb95.js:21:585834) at https://spoprod-a.akamaihd.net/files/sp-client/sp-webpart-workbench-assembly_en-us_27e01b6941bf5cdddecc695bd3bdbb95.js:21:585352 How can fix this problem?. I would like that if I'm logged in Sharepoint obtain the accessToken without relogin into the system. This is my code: export default class MyWebPart extends BaseClientSideWebPart <IWebpartProps> { public render(): void { const config = { auth: { clientId: "xxxxxxxxxxxxxxx", authority: "https://login.microsoftonline.com/yyyyyyyyyyyyyyyyyyy" } }; const myMSALObj = new UserAgentApplication(config); let accessTokenRequest = { scopes: ["user.read"] } myMSALObj.acquireTokenSilent(accessTokenRequest).then(function(accessTokenResponse) { // Acquire token silent success // call API with token let accessToken = accessTokenResponse.accessToken; let scopes = accessTokenResponse.scopes; }).catch(function (error) { //Acquire token silent failure, and send an interactive request console.log(error); if (error.errorMessage.indexOf("interaction_required") !== -1) { myMSALObj.acquireTokenRedirect(accessTokenRequest); } });7.5KViews0likes1Comment