Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HubSiteUrl property does not work when applying provisioning template #1024

Open
JakeStanger opened this issue May 24, 2024 · 0 comments
Open

Comments

@JakeStanger
Copy link

When applying a site-level provisioning template, the HubSiteUrl property always fails with a warning, which is possibly due to a bugged implementation.

Before attempting to make the association, the framework does the following check (TenantExtensions.IsCurrentUserTenantAdmin --> IsCurrentUserTenantAdminViaSPO):

var adminSiteUrl = clientContext.Web.GetTenantAdministrationUrl();
try
{
    // Connect to the Admin Site
    using (var adminContext = clientContext.Clone(adminSiteUrl))
    {
        // Do something with the Tenant Admin Context
        Tenant tenant = new Tenant(adminContext);
        tenant.EnsureProperty(t => t.RootSiteUrl);

        // If we've got access to the tenant admin context, 
        // it means that the currently connecte user is an admin
        return (true);
    }
}
catch
{
    // In case of any connection exception, the user is not an admin
    return (false);
}

This never succeeds and fails 401, falling into the catch block. To me it makes sense that it would fail, because the authentication is against a SharePoint site. Attempting to use that same token for the admin URL won't work because it is a different scope.

To resolve, this check would need to be replaced with one that obtains an admin token correctly.

The issue occurs for both application and delegated permissions.

Originally discussed in #897

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant