Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work with Office365 SharePoint Document Library #155

Closed
PaddyCube opened this issue Feb 15, 2024 · 9 comments
Closed

Work with Office365 SharePoint Document Library #155

PaddyCube opened this issue Feb 15, 2024 · 9 comments

Comments

@PaddyCube
Copy link

PaddyCube commented Feb 15, 2024

Hi there,

your repo lacks in documentation as well as in examples.
Can we use this to upload a BLOB (i.E. Excel file or PDF) to a SharePoint document library in Office365?
Or into a document library of a MS Teams Team (which seems to be the same imo)?

Are there any examples available?

@PaddyCube PaddyCube changed the title Upload BLOB to Office365 SharePoint Document Library Work with Office365 SharePoint Document Library Feb 21, 2024
@MartinPankraz
Copy link
Contributor

MartinPankraz commented Feb 27, 2024

Hi @PaddyCube,

the samples for Azure Blob can be found here. See the sdk for O365 service class to see some details about the SharePoint integration v1.

Regarding Microsoft Teams and SharePoint online integration I would recommend Microsoft Graph. That can be found here too. Design your Graph query using the explorer on the public sandbox or signin to your environment for a quicker implementation.

@vikasbansal2022 any samples that could be shared from our end?

@PaddyCube
Copy link
Author

Basically I need to upload to SharePoint site collection hosted in O365. Can i use this SDK for doing this? We created a ClientID in Admin center, added this ID to an AAD group and granted permissions to this group in our SharePoint Site Collection.

I use this small program to collect all files of a given document library. I'm able to get an AAD token but it always returns 401 when it tries to fetch data from SharePoint. We checked permissions of Client ID a couple of times and they're sufficient.

However, I'm confused about ClientID and SharePoint, V1, V2, ACL and this stuff. So can we use this SDK together with O365 only when we use outdated ACL instead of AAD accounts?

Do we need to switch to Graph these days (whatever this is)?

REPORT z_o365_test.

DATA: o365_sharepoint TYPE REF TO zcl_o365_service_sharepoint.

TRY.
    DATA(o365) = NEW zcl_o365_service_factory( ).
    o365_sharepoinT ?= o365->create( iv_interface_id = 'AZURE_O365' ).

    o365_sharepoint->read_all_file_from_folder(
      EXPORTING
        iv_folder_name = 'Shared%20Documents'
          IMPORTING
          ev_http_status = DATA(http_status)
    ).

  CATCH zcx_adf_service.
ENDTRY.

IF http_status > 299.
  WRITE 'Fehler'.
ENDIF.

@MartinPankraz
Copy link
Contributor

I recommend to reduce the problem space in your integration test by using a plain REST client first. Once you have a working request put the ABAP SDK to work for it. The simplest check is the Graph Explorer. See the endpoints here

@PaddyCube
Copy link
Author

PaddyCube commented Mar 1, 2024

Thanks for highlightning Graph. As SAP Developer, I'm not that familiar with all these MS products.

I had lots of issue to get it running with this SDK. For example, I had to use https://login.microsoftonline.com/{tenant-id}/oauth2/v2.0/token, which seems not to be supported by this SDK. I tried with V1.0 tokens but they're not valid in Graph because the resource "resource": "00000002-0000-0000-c000-000000000000" of token is not valid for Graph

To fix this, I had to change method get_aad_token_clnt_cred of class zcl_adf_service_aad. I added an optional parameter iv_scope for scope as resource is not valid for V2.0 tokens. It only gets added to payload if filled.

Next, I enriched the class zcl_adf_service_graph and the interface by adding methods to read a SharePoint Site, all Lists of a site and all items of a list.

If you're interrested in my changes, I'll fork this repo and create a PR

@MartinPankraz
Copy link
Contributor

Hey @PaddyCube,

a PR would be fantastic!

KR
Martin

@PaddyCube PaddyCube reopened this Mar 4, 2024
@PaddyCube
Copy link
Author

Before creating a PR, I would like to discuss with you, where to store ClientID. In your example, you put it in description of RFC destination. It works but it is odd in my opinion. Description should not contain any data, it should just describe what the connection is good for.

In ZADF_CONFIG, you provide a configuration section for O365 applications. Here we can store ClientID. However you just provide a list of available applications. GRAPH is missing here. Is this the right place for you, should I add it here? Is Graph part of O365 or is it a separate product?
image

Other option I see is here. May we store CLientID either as Key/AAD or as Base URI (Base URI seems to be wrong imo)
image

What would you prefer?

@MartinPankraz
Copy link
Contributor

Microsoft Graph is its own product covering M365 (not only O365).

I lean towards the config screen (2nd screenshot you shared). @vikasbansal2022 what do you prefer?

@vikasbansal2022
Copy link
Contributor

vikasbansal2022 commented Mar 5, 2024

Hi @PaddyCube ,

Key/AAD Column is used to store Secret/Key. Once you save that it gets encrypted and stored in table ZADF_CON_INDX.

Since Client ID is no secret, you can use usual SAP process to store in TVARV via SM30 against some variable and use that in your program code.

Hope it helps.

Regards,
Vikas

@PaddyCube
Copy link
Author

Thanks for your input.
I understand that ClientID in this case can't be stored in ZADF_CONFIG for given reasons.

Patrick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants