Salesforce Superbadge: Configuring External and Named Credentials for API Callouts

Sdílet
Vložit
  • čas přidán 7. 09. 2024
  • In this video,
    I'll guide you through the process of setting up external credentials and named credentials in Salesforce, focusing on configuring authentication and making secure callouts to an external API, specifically for the Research Guardian integration.
    Topics Covered:
    Overview of the use case and business requirements for Max Environmental Science Institute (MESI)
    Step-by-step guide to configuring external credentials
    1. Setting up named credentials in Salesforce
    2. Handling custom authentication headers
    3. Writing Apex code for making secure API callouts
    4. Debugging common issues like unauthorised headers
    Whether you're working on a Salesforce superbadge or looking to enhance your Salesforce integration skills, this tutorial will provide you with the essential steps and tips to successfully configure and manage external and named credentials for secure API integrations.
    Code :
    public with sharing class ResearchServiceController {
    public static Integer processEquipmentsRequest() {
    HttpRequest req = new HttpRequest();
    req.setEndpoint('callout:Research_Guardian/equipments');
    req.setMethod('GET');
    HttpResponse response = new Http().send(req);
    if (response.getStatusCode() == 200) {
    String responseBody = response.getBody();
    System.debug('Available Equipments: ' + responseBody);
    } else {
    System.debug('Callout failed with status code: ' + response.getStatusCode());
    }
    return response.getStatusCode();
    }
    }
    Connect with Me:
    Instagram: ankitkpunjabi
    LinkedIn: / ankitkumar007
    Hashtags:
    #Salesforce #Superbadge #NamedCredentials #ExternalCredentials #APIIntegration #ResearchGuardian #SalesforceDeveloper #MuleSoft #Apex

Komentáře • 38

  • @manoharyenugula3997
    @manoharyenugula3997 Před měsícem +1

    Challenge Not yet complete... here's what's wrong:
    We can't find the appropriate access to the authentication tokens.

    • @AnkitKPunjabi
      @AnkitKPunjabi  Před měsícem

      Ops bad - In video expressions are wrong in custom header
      {!$Credential.Secure_Research.client_id}
      {!$Credential.Secure_Research.client_secret}
      in video expression are encode in quotes like '{!$Credential.Secure_Research.client_secret}' which is wrong. Please update your custom header and try.

    • @petagamer1750
      @petagamer1750 Před měsícem

      Bro just go to permission set name ExtCred - MuleSoft in this object setings serach User External Credentials and give read,edit,create and after that save and go ExtCred - MuleSoft permission set in that below of obeject sents we can searchfor "External Credential Principal Access" in that select"Secure_Research - Infra Collection" then challange will be completed

    • @mohanvadla4341
      @mohanvadla4341 Před měsícem +2

      please give a try adding the External Named Credential that you created(Secure_Research - Infra Collection) to the Permission set(ExtCred - MuleSoft) also .In the permission set , under this option 'External Credential Principal Access'

  • @umrakhan143
    @umrakhan143 Před 2 dny

    hey thanks for the challenge one can you please explain me challenge 2?

    • @AnkitKPunjabi
      @AnkitKPunjabi  Před 20 hodinami

      @@umrakhan143 sure whats the doubt?

    • @umrakhan143
      @umrakhan143 Před 17 hodinami

      @@AnkitKPunjabi stuck 2nd challenge is this issue is that apex class is not successful

  • @vibowplays8716
    @vibowplays8716 Před 17 dny

    Challenge Not yet complete... here's what's wrong:
    We can't find that authentication credentials can dynamically adapt to new credentials when rotated for the 'Secure Research' external credential.

  • @ashokkumarsharma5760
    @ashokkumarsharma5760 Před 14 dny

    Hi @ankitKPunjabi I am following all the steps and creating permission set, public group, adding that group to 2 users everything but still I am now able to see that permission set and public group in principle access and due to this I am getting below error "Challenge Not yet complete... here's what's wrong:
    We can't find the appropriate access to the External Credential Principals." . can you help me in this?

    • @AnkitKPunjabi
      @AnkitKPunjabi  Před 14 dny

      @@ashokkumarsharma5760 check external object read access and in permission set > external credential you need add your new external credential

  • @manoharyenugula3997
    @manoharyenugula3997 Před měsícem +1

    Done everything but still getting below error

    • @petagamer1750
      @petagamer1750 Před měsícem

      Bro just go to permission set name ExtCred - MuleSoft in this object setings serach User External Credentials and give read,edit,create and after that save and go ExtCred - MuleSoft permission set in that below of obeject sents we can searchfor "External Credential Principal Access" in that select"Secure_Research - Infra Collection" then challange will be completed

  • @rangurajeevkumar1694
    @rangurajeevkumar1694 Před 20 hodinami

    I am getting 401 unauthorised error. Could you please help here

    • @AnkitKPunjabi
      @AnkitKPunjabi  Před 20 hodinami

      @@rangurajeevkumar1694 makes sure you have assigned external cred to your permission set

    • @rangurajeevkumar1694
      @rangurajeevkumar1694 Před 18 hodinami

      @@AnkitKPunjabi The ResearchServiceController class doesn't make a successful callout.

    • @rangurajeevkumar1694
      @rangurajeevkumar1694 Před 11 hodinami

      Finally I have done it.

  • @supriyakasukurthi7169
    @supriyakasukurthi7169 Před měsícem

    Upload platform Events superbadge unit also... That helps

    • @AnkitKPunjabi
      @AnkitKPunjabi  Před měsícem

      Currently working on that will be uploading shortly

    • @rajkarun1
      @rajkarun1 Před měsícem

      @@AnkitKPunjabi Thank you Bro

  • @jatindersingh8342
    @jatindersingh8342 Před měsícem

    Getting this error :
    We can’t find the appropriate access to the external credentials principals

    • @AnkitKPunjabi
      @AnkitKPunjabi  Před měsícem

      @@jatindersingh8342 you need to make sure your external credential expression is correct in custom header section

  • @asadshaikh1961
    @asadshaikh1961 Před měsícem

    Challenge Not yet complete... here's what's wrong:
    The ResearchServiceController class doesn't make a successful callout. I am getting this error

    • @AnkitKPunjabi
      @AnkitKPunjabi  Před měsícem

      can you verify you external credential setting? expression should be like !$Credential.Secure_Research.client_id}
      {!$Credential.Secure_Research.client_secret} - in video it's bit wrong

    • @asadshaikh1961
      @asadshaikh1961 Před měsícem

      @@AnkitKPunjabi Yes I verified it's
      client_id
      {!$Credential.Secure_Research.client_id}

      client_secret
      {!$Credential.Secure_Research.client_secret}

    • @asadshaikh1961
      @asadshaikh1961 Před měsícem

      Still it is not working for me, receiving same error

    • @asadshaikh1961
      @asadshaikh1961 Před měsícem

      Yeah I verified the external credentials settings and it is
      client_id
      {!$Credential.Secure_Research.client_id}
      client_secret
      {!$Credential.Secure_Research.client_secret}
      unfortunately still it is not working

    • @asadshaikh1961
      @asadshaikh1961 Před měsícem

      ​@@AnkitKPunjabi I verified still it is showing same error
      external credential setting is as below
      client_id
      {!$Credential.Secure_Research.client_id}
      client_secret
      {!$Credential.Secure_Research.client_secret}

  • @appleguatno6407
    @appleguatno6407 Před měsícem +1

    Challenge Not yet complete... here's what's wrong:
    We can't find that authentication credentials can dynamically adapt to new credentials when rotated for the 'Secure Research' external credential.

    • @AnkitKPunjabi
      @AnkitKPunjabi  Před měsícem

      @@appleguatno6407 see that external credential you adding correctly

    • @mohanvadla4341
      @mohanvadla4341 Před měsícem

      please give a try adding the External Named Credential that you created(Secure_Research - Infra Collection) to the Permission set(ExtCred - MuleSoft) also .In the permission set , under this option 'External Credential Principal Access'

    • @kappagosu4544
      @kappagosu4544 Před měsícem

      @@mohanvadla4341 did that and still same fail​
      ankit skipped a step from somewhere

    • @husnuozaltun3477
      @husnuozaltun3477 Před měsícem

      use these
      {!$Credential.Secure_Research.client_id} and
      {!$Credential.Secure_Research.client_secret} instead fo hard ones on the headers.