Salesforce Superbadge: Configuring External and Named Credentials for API Callouts

Поделиться
HTML-код
  • Опубликовано: 8 сен 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

Комментарии • 40

  • @manoharyenugula3997
    @manoharyenugula3997 Месяц назад +1

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

    • @AnkitKPunjabi
      @AnkitKPunjabi  Месяц назад

      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 Месяц назад

      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 Месяц назад +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 2 дня назад

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

    • @AnkitKPunjabi
      @AnkitKPunjabi  День назад

      @@umrakhan143 sure whats the doubt?

    • @umrakhan143
      @umrakhan143 День назад

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

  • @vibowplays8716
    @vibowplays8716 18 дней назад

    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 14 дней назад

    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  14 дней назад

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

  • @manoharyenugula3997
    @manoharyenugula3997 Месяц назад +1

    Done everything but still getting below error

    • @petagamer1750
      @petagamer1750 Месяц назад

      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 День назад

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

    • @AnkitKPunjabi
      @AnkitKPunjabi  День назад

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

    • @rangurajeevkumar1694
      @rangurajeevkumar1694 День назад

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

    • @rangurajeevkumar1694
      @rangurajeevkumar1694 День назад

      Finally I have done it.

  • @supriyakasukurthi7169
    @supriyakasukurthi7169 Месяц назад

    Upload platform Events superbadge unit also... That helps

    • @AnkitKPunjabi
      @AnkitKPunjabi  Месяц назад

      Currently working on that will be uploading shortly

    • @rajkarun1
      @rajkarun1 Месяц назад

      @@AnkitKPunjabi Thank you Bro

  • @jatindersingh8342
    @jatindersingh8342 Месяц назад

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

    • @AnkitKPunjabi
      @AnkitKPunjabi  Месяц назад

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

  • @asadshaikh1961
    @asadshaikh1961 Месяц назад

    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  Месяц назад

      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 Месяц назад

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

      client_secret
      {!$Credential.Secure_Research.client_secret}

    • @asadshaikh1961
      @asadshaikh1961 Месяц назад

      Still it is not working for me, receiving same error

    • @asadshaikh1961
      @asadshaikh1961 Месяц назад

      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 Месяц назад

      ​@@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 Месяц назад +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  Месяц назад

      @@appleguatno6407 see that external credential you adding correctly

    • @mohanvadla4341
      @mohanvadla4341 Месяц назад

      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 Месяц назад

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

    • @husnuozaltun3477
      @husnuozaltun3477 Месяц назад

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