
Explanation/Reference:
* Example (Target1, Target2) (TokenHelper.GetContextTokenFromRequest,
TokenHelper.ReadAndValidateContextToken)
// The Page_load method fetches the context token and the access token.
// The access token is used by all of the data retrieval methods.
protected void Page_Load(object sender, EventArgs e)
{
string contextTokenString = TokenHelper.GetContextTokenFromRequest(Request); if (contextTokenString != null)
{
contextToken
TokenHelper.ReadAndValidateContextToken(contextTokenString, Request.Url.Authority);
// etc,
}
* Example (Target 3, TokenHelper.GetClientContextWithAccessToken):
// This method retrieves information about the host web by using the CSOM.
private void RetrieveWithCSOM(string accessToken)
{
if (IsPostBack)
{
sharepointUrl = new Uri(Request.QueryString["SPHostUrl"]);
}
ClientContext clientContext
TokenHelper.GetClientContextWithAccessToken(
sharepointUrl.ToString(), accessToken);