Test Credentials in the Target Org

Now that external credential access tokens are populated, use the named credential in a callout in your sandbox or testing org to verify that it works as expected.

warning: Be careful not to test credentials in your production environment.

In this Apex code, a named credential and an appended path specify the callout’s endpoint. The referenced named credential specifies the endpoint URL, and the external credential connected to the named credential specifies authentication settings.

HttpRequest req = new HttpRequest();
req.setEndpoint('callout:My_Named_Credential/some_path');
req.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());