Download and display images from sharepoint (X.Forms PCL)

IngloriousInglorious FRMember

Hi there !

I'm currently developping an app based one Sharepoint REST API and Microsoft Graph. My app is composed mainly with a Tabbed Page, and on the first tab I want to display News from sharepoint. To do so I want to get images from the news, but using the url of the images as Image Source returns me "forbidden" error. So, I decided to find a way to download those images. I've been looking for a way for few days now, and found nothing...

Does anyone knows a way to do that, or why do I have a forbidden access error ?

I bring some precisions, I'm using an HttpClient to authenticate to the tenant with REST API :

       client = new HttpClient();
       Uri mUri = new Uri(App.ReturnUri);
       client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
       var data = await DependencyService.Get<IAuthenticator>()
                     .Authenticate(App.LoginAuthority, App.RestResourceUri, App.ClientId, mUri);
       App.AuthenticationResult = data;
       client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", App.AuthenticationResult.AccessToken);

From that, I hope someone knows if there is a way to download images, or to access to url in order to use them as Source. I succeeded in retrieving URLs but not displaying images, knowing that I can retrieve any other data from sharepoint

Thanks for any help,

Posts

Sign In or Register to comment.