I have create a connected app and authorized in another org and get accessToken for login after that added the username and instance url of another org in custom object and with help of username and org type(production/sabdbox) it give access token and sign in through <instanceurl>/secure/frontdoor.jsp/sid=accessToken but i got error while testing this class

public class MyController{

 public MyController() {      
    Auth.JWT jwt = new Auth.JWT();
    jwt.setSub('[email protected]'); 

    //Additional claims to set scope
    Map<String, Object> claims = new Map<String, Object>();
    claims.put('scope', 'scope name');


    //Create the object that signs the JWT bearer token
    Auth.JWS jws = new Auth.JWS(jwt, 'CertFromCertKeyManagement');

    //Get the resulting JWS in case debugging is required
    String token = jws.getCompactSerialization();

    //Set the token endpoint that the JWT bearer token is posted to
    String tokenEndpoint = 'https://login.salesforce.com/services/oauth2/token';

    //POST the JWT bearer token
    Auth.JWTBearerTokenExchange bearer = new Auth.JWTBearerTokenExchange(tokenEndpoint, jws);

    //Get the access token
    String accessToken = bearer.getAccessToken();

} }

In this class i got null pointer on CertFromCertKeyManagement which is api name of certificate and key management self signed certificate which we upload in connected app i failed the unit test for this call ? can any one help through it ?



You must log in to answer this question.

Browse other questions tagged .