Forum Discussion
Programmatically creation of Office 365 Groups
- Aug 25, 2017
You are one lazy.... ;)
Tenant tenant = new Tenant(clientContext);
var site = tenant.GetSitePropertiesByUrl(siteUrl, false);
clientContext.Load(site, s => s.Status);
site.Context.ExecuteQueryRetry();
var status = site.Status;
Group creation with app-only works fine for me, now. The SharePoint site creation is started instantly and public/private is working as expected.
Currently, I see though an issue where the SharePoint site is in creating state for quite a while, e.g. 75 minutes.
Then I'm really wondering how you do it :) . I digged into PnPCore in GIT
UnifiedGroupsUtility.CreateUnifiedGroup
function and App-only token will create the group, add members and that's it. When its adding logo, it returns "Message: Access is denied. Check credentials and try again." and when creating site it returns "AccessDenied Message: Either scp or roles claim need to be present in the token." In order this to work I have to request token based on users token that is calling the app. With this token I can upload the logo and set it to private/public.
I tried whatever possible, but still the same. Today I will try to delete the site, but I'm nearly sure if I delete the group as api-only perm. it will leave the site orphaned, because this is connected with the user token again. So it is the user who should do the action.
Thank you for your advice.
cc: Mikael Svenson
- Mikael SvensonAug 25, 2017Iron ContributorWe're using the New-PnPUnifiedGroup commandlet, and setting public/private works.
Logo is not supported (yet) using app only, as mentioned in the MS Graph documentation - https://developer.microsoft.com/en-us/graph/docs/concepts/known_issues- Tomas PaulasAug 25, 2017Brass Contributor
OK, now I understand, but that is PowerShell. I'm talking c#. PowerShell is nice and powerfull tool for administration and automation of tasks, however we need to implement it in c# .NET webAPI that is offering integration with other business systems, so users can create group and site (that acts as project team site) on demand from the ERP system.
So, I will stick to use of both tokens for now and wait with hope for Microsoft's next steps. :)
Tomas
- Mikael SvensonAug 25, 2017Iron ContributorYou can easily look at the code of the PnP posh and see what C# is behind it :)