Skip to main content

#Named Credentials0 discussing

Named Credentials: Salesforce Developers Ask Me Anything June 2024

 

Named Credentials make authentication easy, with no need to worry about details like protocol implementation, endpoint allowlisting, or token storage. Want to learn more? Bring your questions to our monthly Ask Me Anything, hosted by Developer Advocate @Alba Rivas. Product Managers @Ross Belmont and @Andrea Guzman will answer your questions on this topic live.

 

Date: Wednesday June 26, 2024

Time: 9am PT

Theme: Named Credentials

Registration: https://sforce.co/4cbvhbW

Hope to see you there!

Named Credentials: Salesforce Developers Ask Me Anything June 2024 Named Credentials make authentication easy, with no need to worry about details like protocol implementation, endpoint allowlisting,

#Named Credentials #Integration #CommUpdates #SFDevsAMA

3 comments
0/9000

We are attempting to connect one Salesforce org to multiple others (Production / Sandbox) using a web server login flow from a managed package. Our approach involves storing 'refresh_token' and 'access_token' in either custom settings or custom metadata. Is this method optimal, or could it potentially pose security risks.Is there any other ways to store token in salesforce.

 

If above ways are wrong, please suggest any other alternate ways to connect multiple salesforce org from managed package.

3 answers
  1. Feb 26, 2025, 10:36 AM

    If you're looking for a coding approach, using Named Credentials with OAuth 2.0 is a secure way to connect multiple Salesforce orgs from a managed package. However, if you want a no-code alternative, Skyvia (https://skyvia.com/connectors/salesforce) provides a seamless way to sync data between Salesforce orgs without managing authentication manually. It also supports scheduled and automated syncs.

0/9000

Resources from the Salesforce Developers Ask Me Anything on Named Credentials

 

I hope you joined us for the fantastic #SFDevsAMA on Wednesday 26 June 2024 featuring @Alba Rivas and @Ross Belmont (with apologies from @Andrea Guzman). 

 

Ross and Alba loved answering your questions about Named Credentials. If you missed it, don't worry - we recorded the series and our experts have provided some great resources that our experts for you to continue your learning! 

 

#Apex #Ask An Expert #Named Credentials #Integration

6 comments
0/9000

Hi all,

 

I have a requirement where we are integrating Salesforce with an external system. It is a 1-way communication where SF will use their API to pull in the necessary data. For authorization purpose they are using oAuth 2.0 Client Credentials with certificate (Microsoft oAuth link). They have provided us with the following information

1. Client ID

2. Tenant ID

3. .pfx certificate

4. Token Endpoint

5. scope

6. app endpoint.

 

I have tried a couple of ways using named credentials, but not able to establish the connection.

 

I would highly appreciate any help here on how to achieve this using salesforce. 

Thank you,

Aiswarya

 

#Identity & Access Management #Salesforce Developer #Named Credentials #Integration #TrailblazerCommunity #Advanced Administrator

5 answers
  1. Mar 1, 2024, 8:21 PM

    Steps taken so far:

    1. Converted .pfx certificate into JKS keystore file using openssl as pfx file format is not compatible with salesforce

    2. Uploaded the certificate into the client and key management setup

    3. Created an external credential with authentication protocol type as Client credentials with JWT assertion.

    4. Configured the JWT claims.

    5. Created a named credential and linked it with the external credential.

    6. Apex code snippet to test the connection.

    7. The response received was status code = 403 which indicates the credentials we are sending are wrong.

     

    Microsoft requires the following information in request body to authenticate.

    1. Client_assertion_type : available

    2. Grant_type - available

    3. Client_assertion - NOT AVAILABLE

    4. Scope - available

    5. Tenant - available

    6. Client_id - available

     

    The main questions are:

    1. does Salesforce generate the client_assertion and send it in the request or do we need to generate it?

    2. If we need to generate, what is the way to do this in Salesforce or Apex?

     

    #Integration #Salesforce Developer #Identity & Access Management #Named Credentials #Advanced Administrator #TrailblazerCommunity

0/9000

I have been reading and searching and reading and searching information on external and named credentials. I feel like i understand the architecture and purpose and I want to use them, but every time I try to do so I get lost in the details.

 

Right now I am stuck on what a Principal is.  When creating an external credential, when and why would I create a principal, and what would I use it for.  I have found no definition for this.

 

Thanks in advance.

1 answer
  1. Jan 20, 2024, 12:34 PM

    https://help.salesforce.com/s/articleView?id=sf.named_credentials_about.htm&type=5

    "A named credential supports various authentication protocols. You can set up each named credential to use an org-wide named principal or per-user authentication.

    A named principal applies the same credential or authentication configuration for the entire org, while per-user authentication provides access control at the individual user level."

0/9000

Hi All,

I had created a legacy named Credential with 

Identity Type = Named Principal

Authentication Protocol = OAuth 2.0 and when I go to a profile which is having salesforce platform license I'm not able to see the named credential in the Named Credential Access setting on the profile.

Is there anything im missing or it has deprecated?

also as I have used I have given access to

Enable User External Credentials in "Object Settings".

But I'm not able to add External Credentials to "External Credential Principal Access"as i could see none.

is there any way I could add named credential access into the profile? #Integration #India #Ask An Expert #Httpcallout #Named Credentials 

2 answers
  1. Nov 29, 2023, 12:06 PM

    Thanks for the reply @Kalpesh Ketkar

    I went through the above the steps but still not able to make callout for the profiles other than system admin

0/9000

Really simple Authorisation Header for lots of @External Services.  

Password Authentication Named Credentials will always encode the username:password.

It would be ideal if the username field was not mandatory so that just the password is encoded to create the encodedkey for the Authorisation Header.

 

Any way to do this declaratively?

 

#Enhanced External Services #Named Credentials

4 answers
  1. Sep 7, 2022, 3:28 PM

    Thanks @Ross Belmont - this is EXACTLY what is needed to unlock the potential for External Services.   This is a game changer for no-code / low-code pioneers. Thanks!!  

     

    We have 3 services we wish to integrate using this Custom Protocol capability and I'll let you know how we get on.  Thanks again.   S

0/9000

I am looking to call Zoom from Salesforce by calling the API directly, as I need to make some calls in a Flow that isn’t supported by the Zoom marketplace app in Salesforce.

 Here is what I’ve gotten in Salesforce so far:

  1. Created a named credential with JWT Tokens (I believe this is wrong though)
  2. Created an External service with the Zoom APIs, specifically for the report/users/{0}/meetings endpoint.
  3. Created a flow to call the above endpoint

When running the flow, this is the error I get:

Error Occurred: Unable to map response for parameter: 200 and invokable action: Zoom2.reportMeetings. Received response:

 (note the blank "received response")  

My first inclination is that my named credential to set up the JWT token was incorrect.

Has anyone on this forum had success creating a named JWT credential on Salesforce to call Zoom?   I’ve successfully used JWT tokens in other apps but am not sure if I’m mapping things correctly in Salesforce.

 

#Named Credentials #External Services #Zoom

2 answers
  1. Nov 8, 2021, 12:42 PM

    Hi Jeremy, I have used a JWT app to connect to the Zoom API with Apex. I have the client id/secret stored in a custom setting. Here is the relevant Apex that generates the token I use to make API calls. I haven't used Flow to make API calls but this could be created as an invocable method you could call from Flow. Hope it helps.  

    public static String createToken() {

    String token='';

    String alg = 'HS256';

    String typ = 'JWT';

    String headerJson = JSON.serialize(new Header(alg,typ));

    String iss = ZoomAPI__c.getOrgDefaults().ClientID__c;

    String exp = String.valueOf(System.currentTimeMillis() + 60 * 60 * 1000);

    String bodyJson = JSON.serialize(new Body(iss,exp));

    token = EncodingUtil.base64Encode(Blob.valueOf(headerJson))

    + '.' + EncodingUtil.base64Encode(Blob.valueOf(bodyJson));

    String signature = EncodingUtil.base64Encode(Crypto.generateMac('HMACSHA256',

    Blob.valueOf(token),

    Blob.valueOf(ZoomAPI__c.getOrgDefaults().APISecret__c)

    );

    token += '.' + signature;

    return token;

    }

0/9000

Hello Team,

I am new to Externa Service.

 

I am trying to connect a FLOW using external services to an API endpoint, with OAUTH2.0 setup in Named Credentials using per user.

 

I have checked the Auth header set Checkbox. However, when I am running the flow, It always gives me 401 Error(Auth Header Not set).

 

Please let me know the next steps if someone has gone through the same.

 

Also, we are required to send the access token in the header to the API, so how can we achieve that from the flow.

 

Do we need to include that part in Swagger JSON, if yes, how will i get and assign the token in Header from Flow?

 

Thank you again for reviewing and assisting on this.

5 comments
0/9000

Lightning removes the URL parameters from the record detail page if they are not passed in a specific format. This creates an issue when we do Authentication with a third-party service.

Check how we can solve this with Named credentials and do Authentication with Google drive and upload files.

We will also cover the below points:

1. Pass record id in Screen Flow from the Lightning record detail page.

2. Use Named credentials to do authentication to Google API.

3. Make a multipart request to Google Drive API and pass file metadata.

4. Reset collection variable in flow.

Upload File to Google Drive Using Flow and Named Credentials

2 comments
0/9000