🔐 OAuth 2.0 User Guide

Complete setup and usage instructions

v26.2.0 walter75 Consulting BC Cloud

📚 Quick Navigation


Introduction

The walter75 - OAuth 2.0 extension provides a comprehensive OAuth 2.0 authentication framework for integrating Microsoft Dynamics 365 Business Central with external APIs and services.

🔐 Secure Authentication

Industry-standard OAuth 2.0 protocol

🔄 Automatic Token Refresh

Handles token expiration automatically

📊 Token Management

Track and manage access tokens centrally

🔗 Multi-Service Support

Configure multiple API connections

🛡️ Credential Security

Encrypted storage of sensitive data


Setup

📋 Prerequisites

Before using OAuth 2.0 authentication, you need:


Creating an OAuth Application

1

Open OAuth Applications

Search for "OAuth Applications" in Business Central and click + New to create a new application

2

Configure Basic Settings

General Information:

  • Code: Unique identifier (e.g., "SENDCLOUD", "PRINTNODE")
  • Description: Descriptive name (e.g., "SendCloud Shipping API")
  • Active: Enable to activate the application
3

Configure OAuth Endpoints

Authentication Settings:

  • Authorization URL: OAuth authorization endpoint
    https://api.example.com/oauth/authorize
  • Token URL: Token exchange endpoint
    https://api.example.com/oauth/token
  • Scope: Required permissions (space-separated)
    read write shipping
4

Enter Credentials

Client Credentials:

  • Client ID: Application client identifier
  • Client Secret: Secret key (stored encrypted)

⚠️ Security Note: The Client Secret is stored encrypted. Never share these credentials publicly.

5

Configure Grant Type

Select OAuth 2.0 flow:

  • Authorization Code: User-based authentication
  • Client Credentials: Service-to-service (recommended)
  • Password: Username/password flow
  • Refresh Token: Automatic refresh
6

Save and Test

  1. Click OK to save the configuration
  2. Use the "Request Token" action to test
  3. If successful, an access token will be generated

Managing Access Tokens

🔑 Viewing Active Tokens

  1. Open your OAuth Application Card
  2. Navigate to RelatedAccess Tokens
  3. View all generated tokens with their expiration times

Token Information Displayed:

Automatic Token Refresh

The system automatically refreshes tokens before they expire if:

Manual Token Refresh

1

Open OAuth Application

Navigate to the OAuth Application Card

2

Refresh Token

Click ActionsRefresh Token

3

Verify Success

The system will request a new token using the refresh token

Revoking Tokens

🚫 To invalidate a token:

  1. Navigate to RelatedAccess Tokens
  2. Select the token to revoke
  3. Click Revoke Token
  4. Confirm the action

Troubleshooting

❌ Invalid Client Credentials

Cause: Client ID or Secret is incorrect

Solution:

  • Verify credentials in API dashboard
  • Update OAuth Application
  • Check for extra spaces

⏰ Token Expired

Cause: Access token reached expiration

Solution:

  • System auto-refreshes normally
  • Manually refresh if needed
  • Verify refresh tokens enabled

🔒 Invalid Scope

Cause: Requested scopes not allowed

Solution:

  • Check API documentation
  • Request additional scopes
  • Update Scope field

🚫 Authorization Failed

Cause: Multiple possible issues

Solution:

  • Check OAuth Log
  • Verify URLs are correct
  • Test API externally

Checking OAuth Logs

📊 Detailed Troubleshooting

  1. Search for "OAuth Log Entries"
  2. Filter by your OAuth Application code
  3. Review error messages and response codes
  4. Use timestamps to correlate with failed requests

Best Practices

✅ Do

  • Use descriptive codes
  • Review unused tokens
  • Test after API updates
  • Keep secrets secure
  • Monitor expiration

❌ Don't

  • Share Client Secrets
  • Reuse applications
  • Ignore refresh failures
  • Disable error logging