OneDrive Connector
Documentation
Version: 9
Documentation

Authentication Application Credentials with Certificate (Sign JWT with Private Key)


Instructions

To use Certificate-Based Authentication Setup please follow the steps listed in [Application Credentials] authentication and once done come back here to finish next stsps.

This guide walks you through setting up a certificate-based authentication flow for Microsoft Graph or other Azure AD protected APIs using client credentials and a JWT.

Step 1: Generate a Self-Signed Certificate

You can use OpenSSL or any other way to generate Certificate file but make it simple below example uses PowerShell. Open PowerShell and execute code listed in below steps.

# Run this in PowerShell
#Change .AddYears(1) to desired number. By default it expires certificate in one year as per below code.

$cert = New-SelfSignedCertificate `
  -Subject "CN=MyClientAppCert" `
  -KeySpec Signature `
  -KeyExportPolicy Exportable `
  -KeyLength 2048 `
  -CertStoreLocation "Cert:\CurrentUser\My" `
  -KeyAlgorithm RSA `
  -HashAlgorithm SHA256 `
  -NotAfter (Get-Date).AddYears(1) `
  -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider"

# Export private key (.pfx)  - Keep this with you to make API calls (SECRET KEY - DONOT SHARE)
$pfxPath = "$env:USERPROFILE\Desktop\private_key.pfx"
$pwd = ConvertTo-SecureString -String "yourStrongPassword123" -Force -AsPlainText
Export-PfxCertificate -Cert $cert -FilePath $pfxPath -Password $pwd

# Export public certificate (.cer) - UPLOAD this to Azure Portal
$cerPath = "$env:USERPROFILE\Desktop\public_key.cer"
Export-Certificate -Cert $cert -FilePath $cerPath

Step 2: Register or Configure an App in Azure AD

  1. Go to https://portal.azure.com
  2. Navigate to Azure Active Directory > App registrations
  3. Click + New registration or open an existing app
  4. Copy the Application (client) ID and Directory (tenant) ID

Step 3: Upload the Certificate

  1. In your App Registration, go to Certificates & secrets
  2. Under Certificates, click Upload certificate
  3. Select the .cer file (public certificate)
  4. Click Add

Step 4: Grant API Permissions

  1. Go to the API permissions tab
  2. Click Add a permission
  3. Select Microsoft Graph (or another API)
  4. Choose Application permissions
  5. Add scopes such as:
    • Sites.Read.All
    • Sites.ReadWrite.All
    • Files.Read.All
    • Files.ReadWrite.All
    • email
    • offline_access
    • openid
    • profile
    • User.Read
  6. Click Grant admin consent (requires admin)

Step 5: Use PFX file

Once both files generated perform the following steps to use PFX file., , Use the Certificate file (*.pfx) Now its time to use pfx file generated in the previous step. PFX file contains private key and public key both.
  1. On ZappySys Connection UI Go to Certificate Tab
  2. Change Storage Mode to Local PFX File (or you can Import PFX file in Certificate Storage - User Store / Machine Store and use that way)
  3. Supply the pfx file path or select certificate from Local Certificate Store if you imported that way in earlier step
  4. Supply the certificate password (same password used in earlier PowerShell script)
  5. Test connection see everything is good

Parameters

Parameter Label Required Default value Options Description
TokenUrl Token URL YES
Name Value
For Single Tenant https://login.microsoftonline.com/{ENTER-TENANT-ID-HERE}/oauth2/v2.0/token
For Multi Tenant https://login.microsoftonline.com/common/oauth2/v2.0/token
ClientId Client ID YES
Certificate Certificate: *** Configure [Client Certificate] Tab *** YES
SiteId Default Site Id YES root Specify a site
DriveId Default Drive Id Specify a default Drive Id you like to use for operations.
RetryMode RetryMode RetryWhenStatusCodeMatch
Name Value
None None
RetryAny RetryAny
RetryWhenStatusCodeMatch RetryWhenStatusCodeMatch
RetryStatusCodeList RetryStatusCodeList 429|503|423 429 is API limit reached, 423 is File locked
RetryCountMax RetryCountMax 5
RetryMultiplyWaitTime RetryMultiplyWaitTime True
SearchOptionForNonIndexedFields Search Option For Non-Indexed Fields (Default=Blank - Search Only Indexed)
Name Value
Search Only Indexed
Search Both Indexed and Non-Indexed HonorNonIndexedQueriesWarningMayFailRandomly
If you wish to do certain operations e.g. search / order by on non-indexed fields then you have to set this option to HonorNonIndexedQueriesWarningMayFailRandomly. By default filter / orderby on non-indexed fields not allowed.
ExtraHeaders Extra Headers (e.g. Header1:AAA||Header2:BBB)
Name Value
MyHeader1:AAA MyHeader1:AAA
MyHeader1:AAA||MyHeader2:BBB MyHeader1:AAA||MyHeader2:BBB
IsAppCred IsAppCred 1 For internal use only