I'm the global administrator and can successfully create site collections through the admin site in office 365 but when I try to create a site with the code below I get an Access Denied error. Any ideas?
using (ClientContext ctx = new ClientContext("https://tenant-admin.sharepoint.com"))
{
ctx.Credentials = new SharePointOnlineCredentials("username", GetPassword());
try
{
Tenant _tenant = new Tenant(ctx);
var _newsite = new SiteCreationProperties();
_newsite.Title = siteRequest.Title;
_newsite.Url = siteRequest.Url;
_newsite.Owner = siteRequest.SiteOwner.Name;
_newsite.Template = template.RootTemplate;
_newsite.Lcid = siteRequest.Lcid;
_newsite.TimeZoneId = siteRequest.TimeZoneId;
SpoOperation op = _tenant.CreateSite(_newsite);
ctx.Load(_tenant);
ctx.Load(op, i => i.IsComplete);
ctx.ExecuteQuery(); --> This is where the access denied error occurs.