• 23 Oct

    How to access SharePoint Rest API using OAuth

    Version v2023 is needed and available here.

    Update: A newer and preferred OAuth2 setup is explained in the following blog article: link

    This Authorization method using OAuth2 was tested by a customer of us (Eddy, we really appreciate this). It is based on the following article.

    As mentioned in the article, first you’ll need to register an AD app with your AD Tenant. It will assign you the necessary information you need for the OAuth2 setup

    Feedback customer:

    • This required the following settings in Azure. Maybe only the delegated permissions under Graph are enough, didn’t play too much.

    Sharepoint OAuth2 authorization

    • Also the the redirect url should be set for the app, and ID_token must be enabled.

    Sharepoint OAuth2 authorization

    Limagito File Mover Setup:

    • In this case the Auth Type in our SharePoint setup should be set to: ‘OAuth 2.0 Authorization Code Flow’

    SharePoint OAuth Authentication

    • OAuth2 Setup:
      • Disable ‘Code Challenge’
        • Seems to work also when enabled (tested by customer)
      • Enable ‘Include Nonce’
      • Set ‘Authorization Endpoint URL’
        • https://login.microsoftonline.com/%realm/oauth2/authorize
        • %realm will be replaced by the Realm value (= Tenant or Tenant_ID). You can also enter the full URL including the Tenant.
      • Set ‘Token Endpoint URL’
        • https://login.windows.net/%realm/oauth2/token?api-version=1.0
        • %realm will be replaced by the Realm value (= Tenant or Tenant_ID). You can also enter the full URL including the Tenant.
      • Enter your Client ID and Client Secret (please check the article howto create them)
      • Set ‘Scope’ to:  openid
        • If you don’t receive a Refresh Token, change it to:  openid offline_access
        • Customer used: https://<Tenant>.sharepoint.com/.default
      • Set ‘Resource’ to:  https://graph.microsoft.com/
        • Customer used: https://<Tenant>.sharepoint.com
      • Set Response Mode to:  form_post
      • Set Response Type to:  id_token+code
      • When using %realm in the ‘Authorization or Token Endpoint URL’
        • Please set ‘Realm’ to your Tenant of Tenant_ID

    After the setup, please click on the <Get> button. If you get a firewall popup, you’ll need to accept this otherwise we will not be able to capture the Tokens.

    Follow the steps in the browser and it should fill the Refresh and Access Token afterwards. Do not forget to click <Save>.

    • OAuth2 setup  used by customer (info about the .default Scope: here):

    access SharePoint Rest API using OAuth

    • OAuth2 setup we received from our SharePoint source code provider:

    SharePoint OAuth Authentication

    • Common Setup:

    If you want extra debug information during the test, please enable ‘Add Control Information to Log’

    SharePoint OAuth Authentication

    #Filetransfer #SharePoint

    If you need any help with this ‘how-to-access-sharepoint-rest-api-using-oauth’ option, please let us know.

    Best Regards,

    Limagito Team

  • 01 Oct

    I have a task that needs to grab sets of files

    Q: I have a task that needs to grab sets of files. Pdf files that have “A01” and “A06” OR files that have “A01” and A08” in their filename. Could this be accomplished?

    A: So you would like us to check if pdf file A08 is available and if so then grab pdf files with A01 and A08 in their filename. If pdf file A08 is not available check the same but then using A06 in the filename.  Meaning a set of files and grabbing the first and last page pdf file. Yes, this is possible.

    • As Source we will use a windows folder. This folder will contain the pdf files.

    Limagito File Mover Source Setup

    • In the ‘File Filter’ we are going to use the ‘File Name Include’ filter option. Add the parameter %VSA to this filter. This %VSA (Var String A) will get its value from  a script that we will add in the next step.

    Limagito File Mover File Filter Setup

    • In the ‘Advanced’ tab of the ‘File Filter Setup’  we need to enable ‘Allow parameters in File Name Filter’.

    Limagito File Mover File Filter Advanced

    • Next, please open the ‘Pascal Script’ option:

    Limagito File Mover Pascal Script

    • Enable and add the following ‘On Rule Begin’ script:
    Begin
      psExitCode:= 0;
      // ... add your code here
      psLogWrite(1, '', 'Source Path: ' + psSourcePath);
      If psCountFiles(psSourcePath, '*A08*.pdf', False) >= 1 Then
      Begin
        psLogWrite(1, '', 'Found A08');
        psVSA := '*A01*.pdf;*A08*.pdf';
        psExitCode:= 1;
      End
      Else
      Begin
        If psCountFiles(psSourcePath, '*A06*.pdf', False) >= 1 Then
        Begin
          psLogWrite(1, '', 'Found A06');
          psVSA := '*A01*.pdf;*A06*.pdf';
          psExitCode:= 1;
        End;      
      End;
    End.

    Limagito File Mover Pascal Script Setup

    • As Destination we used a Windows folder:

    Limagito File Mover Destination Setup

    • First test with 6 pdf files in the Source, A01 to A06

    • RunTime log result, only pdf file A01 and A06 are copied:

    Limagito File Mover RunTime log

    • Second test with 6 pdf files in the Source, A01 to A08

    • RunTime log result, only pdf file A01 and A08 are copied:

    Limagito File Mover RunTime Log

    If you need any help with this ‘grab sets of files’ request, please let us know.

    Best Regards,

    Limagito Team

    #filetransfer #filemanagement

    By Limagito-Team Pascal Script
1 2
SEARCH