Read PDF file from SharePoint in android via graph api with java.

Anonymous
2023-03-19T18:58:54.5133333+00:00

Its my first time to work with MSAL.

i am using the graph api to read data but i'm getting a sharepoint file link .

i want to download that file into my app but it is giving 403 error code (with using MSAL auth token) but i can access that file without login with that url on chrome or any other browser .

Q1 is there any special permission required to access share point file on android ?

My Permissions :

permissions

Q2 can someone share sample auth json file or manifest file ?

i am using this auth json file.

{  "client_id" : "xxxx", 
 "authorization_user_agent" : "DEFAULT", 
 "redirect_uri" : "msauth://com.example.xxxx",  
"account_mode" : "SINGLE",
  "broker_redirect_uri_registered": false,
  "shared_device_mode_supported": true, 
 "authorities" : [  
  {      "type": "AAD",   
   "audience": {        "type": "AzureADandPersonalMicrosoftAccount",  
      "tenant_id": "common"      }   
 }  ]}

Q3 Any example to read file in android java or kotlin ?

This is my REST call with retrofit client.

@Streaming
@GET
fun downloadPdf(  
  @Url urlPdf: String,   
 @Header("Authorization") token: String,): Call<ResponseBody>
Microsoft 365 and Office | SharePoint | Development
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,551 Reputation points Microsoft External Staff
    2023-03-20T01:38:49.82+00:00

    Hi @Sakshi Sharma,

    You will need sites.readall permission to view the PDF file from SharePoint in android. It's same as the permission on other environment. For the samples in MSAL you can refer to the document

    https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-configuration

    And since our forum is focus on C#. You can raise a new ticket in techcommunity. You might get some more professional advice there.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.