Nov 11 2016 06:34 AM
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:
string realm = TokenHelper.GetRealmFromTargetUrl(webUri); var token = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, webUri.Authority, realm).AccessToken; using (var ctx = TokenHelper.GetClientContextWithAccessToken(webFullUrl.ToString(), token)) { ...
Nov 11 2016 08:06 AM
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'