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

Sakshi Sharma 0 Reputation points
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 Graph SDK
Microsoft Graph SDK
A Microsoft software developer kit designed to simplify building high-quality, efficient, and resilient applications that access Microsoft Graph.
989 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,243 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 24,121 Reputation points Microsoft Vendor
    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.