0

We have a multi-site environment where each site has its own redirect URL. We want to use a single Client ID and Secret for our application but register multiple redirect URIs to it. Is it possible to add multiple URLs in below registration form:

enter image description here

1

I don't think there is possible solution to add on multiple URLs on the SharePoint online app registration form.

But from what i understand there is another way to achieve use a single Client ID and Secret for application and perform multiple redirects.

You can control the redirect url using the appredirect.aspx by specifying the redirect_uri parameter if you need to redirect from the default one check here for reference.

Basiclly it call the subsite page containing the below JS to install the app.

var url = String.format(
"{0}/_layouts/15/appredirect.aspx?client_id={1}&redirect_uri=https://***.azurewebsites.net/<<controller>>/<<view method containing the code to install the app>>?{{StandardTokens}}",
<<subsite url>>, "<<client id>>");

window.location.href = url;

The above javascript calls the appredirect.aspx page which then calls the app site as below,

https://****.azurewebsites.net/home?SPHostUrl=<<subsiteurl>>&SPLanguage=en-US&SPClientTag=1&SPProductNumber=**&SPAppWebUrl=<<weburl>>

Note: The above can be extended to check for the successful installation of the app and display an error message accordingly.

SPWeb.LoadAndInstallWeb equivalent REST / Javascript CSOM is also available here.

Here are some relevant links:

Use the redirect URL in an add-in that asks for permissions on the fly

Redirect URIs and a sample redirect page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.