Overview: The use of Apps (specifically SPHA) in SharePoint seems to be misunderstood, developers and architects often want to use the App model for functionality that folks have built using previous versions of SharePoint. App are reusable pieces of custom logic akin to a specialised document library.
The app needs to be deployed to the catalogue store and permissions granted to leverage SP functionality.
Permissions in SPHA run in the context of the current user as opposed to Provider Hosted Apps that can run in either: current user context, app context or app and current user context.
var termSetName = //document.getElementById('termsetID').value;
var locale = 1033; // your locale. Here is English
var context = SP.ClientContext.get_current(); //User the current users context.
var taxonomySession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
var termStore = taxonomySession.getDefaultSiteCollectionTermStore();
var termSets = termStore.getTermSetsByName(termSetName, locale);
var termSet = termSets.getByName(termSetName);
var terms = termSet.getAllTerms();
var termEnumerator = terms.getEnumerator();
var termList = "Terms: <br/>";
var currentTerm = termEnumerator.get_current();
termList += currentTerm.get_name() + "<br/>";
Windows.alert(termList);// Output to the screen
// Notify user of error
The user only needs to be a visitor to have read access to the term store. JS works in the same way whether inside an SPHA or within a page on a SharePoint site.
Provider-Hosted Apps (PHA) can use either combination of:
- context token (user context)
- user+app access token
- app-only access