mirror of
https://github.com/forcedotcom/afv-library.git
synced 2026-07-30 03:09:50 +08:00
52 lines
1.8 KiB
XML
52 lines
1.8 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!--
|
|
Named Credential Template: OAuth 2.0 Client Credentials Flow
|
|
|
|
Use Case: Server-to-server integration without user context
|
|
- Machine-to-machine authentication
|
|
- Backend service integrations
|
|
- Scheduled jobs calling external APIs
|
|
|
|
Setup Steps:
|
|
1. Replace all {{placeholder}} values
|
|
2. Create corresponding Auth Provider if using OAuth
|
|
3. Deploy to org
|
|
4. Store client credentials in Setup → Named Credentials
|
|
|
|
File Location: force-app/main/default/namedCredentials/{{CredentialName}}.namedCredential-meta.xml
|
|
-->
|
|
<NamedCredential xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
<fullName>{{CredentialName}}</fullName>
|
|
<label>{{CredentialLabel}}</label>
|
|
|
|
<!-- Base URL for the external service (without trailing slash) -->
|
|
<endpoint>{{BaseEndpoint}}</endpoint>
|
|
|
|
<!-- Authentication Configuration -->
|
|
<principalType>NamedUser</principalType>
|
|
<protocol>Oauth</protocol>
|
|
|
|
<!-- OAuth Settings -->
|
|
<!-- Token endpoint where Salesforce requests access tokens -->
|
|
<oauthTokenEndpoint>{{TokenEndpoint}}</oauthTokenEndpoint>
|
|
|
|
<!-- Space-separated OAuth scopes (e.g., "read write") -->
|
|
<oauthScope>{{Scopes}}</oauthScope>
|
|
|
|
<!-- Auth Provider reference (create this first in Setup → Auth Providers) -->
|
|
<!-- <authProvider>{{AuthProviderName}}</authProvider> -->
|
|
|
|
<!-- Request Options -->
|
|
<generateAuthorizationHeader>true</generateAuthorizationHeader>
|
|
<allowMergeFieldsInBody>true</allowMergeFieldsInBody>
|
|
<allowMergeFieldsInHeader>true</allowMergeFieldsInHeader>
|
|
|
|
<!--
|
|
Client ID and Secret are stored via UI, NOT in metadata for security.
|
|
After deployment:
|
|
1. Go to Setup → Named Credentials
|
|
2. Edit the credential
|
|
3. Enter Client ID and Client Secret
|
|
-->
|
|
</NamedCredential>
|