Hi there
Don't seem to be getting anywhere with this, i'm trying to use CSOM to download and resize an image file. Sound simple enough but i seem to be having permission issue. Keep getting The remote server returned an error: (401) Unauthorized
My code looks like this:
using (ClientContext clientContext = TokenHelper.CreateRemoteEventReceiverClientContext(properties))
{
if (clientContext != null)
{
try
{
clientContext.Credentials = new NetworkCredential("username", "password", "domain");
I also tried to use App only credentials like this but no luck:
Uri siteUri = new Uri(contextClient.Url);string realm = TokenHelper.GetRealmFromTargetUrl(siteUri);
//Get the Access token from the URL
//Requires this app to be registered with the tenant
string accessToken = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, siteUri.Authority, realm).AccessToken;
The permission is blows up here on this line:
FileInformation fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, fileRef);
Any help will be appreciated.