F5 debugging with Add-in Only Permissions


I just want to confirm that I'm not missing something here. I'm working on a provisioning app that uses Add-in Only permissions to execute a timer job in SharePoint 2016 On-Premises.  In typical Add-in development with Visual Studio and F5 debugging, there is no need to use AppRegNew.aspx to register an application with SharePoint as the ClientId and Secret are generated at runtime.


However, I am running into issues using F5 debugging when calling the TokenHelper.GetAppOnlyAccessToken and job.UseAppOnlyAuthentication(ClientId,ClientSecret) methods.  Both throw errors.  A couple of questions:


  1. Do I need to pre-register the app with AppRegNew.aspx in order to use Add-in Only Authentication?  Or is this unexpected behavior?
  2. I noticed that alll of the samples on GitHub for async provisioning use Add-in Only Authentication; is it possible to use Network Credential authentication when creating the Tenant client context? Relevant code below:
 string realm = TokenHelper.GetRealmFromTargetUrl(webUri);
            var token = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, webUri.Authority, realm).AccessToken;
            using (var ctx = TokenHelper.GetClientContextWithAccessToken(webFullUrl.ToString(), token))

1 Reply

FWIW, here is the error I receive when attempting to instantiate the tenant context with Add-in Only authentication: 

{"The remote server returned an error: (400) Bad Request. - {\"error\":\"invalid_request\",\"error_description\":\"AADSTS90002: No service namespace named 'dce143e1-9800-4b22-b344-8d9f20b553d0'