I am new to developing provider hosted apps and going through some code snippets over the web to see how to get the context of the host web (or app web) to work on lists and libraries etc through the app. I read through the OAUTH concepts and the token flow for context token and accesstoken.
I saw in some of the code snippets that the client context is obtained using
var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);
using (var clientContext = spContext.CreateUserClientContextForSPHost())
However at a few places it is retrieved using the contexttoken
var contextToken = TokenHelper.GetContextTokenFromRequest(Page.Request);
var hostWeb = Page.Request["SPHostUrl"];
using (var clientContext = TokenHelper.GetClientContextWithContextToken(hostWeb, contextToken, Request.Url.Authority))
So my question is, when are we required to work with context and access tokens in the code to get the client context. Or is it that both the methods mentioned above essentially do the same thing and any one can be used to get the clientcontext ?