I am trying to implement the sentiment api but having issue while generating the access token.
I have uploaded einstein_platform.pem file in Files in Salesforce.
ContentVersion con = [SELECT Title
,VersionData
FROM ContentVersion
WHERE Title = 'einstein_platform'
OR Title = 'predictive_services'
ORDER BY Title
LIMIT 1];
String key = con.VersionData.tostring();
key = key.replace( '-----BEGIN RSA PRIVATE KEY-----', '' );
key = key.replace( '-----END RSA PRIVATE KEY-----', '' );
key = key.replace( '\n', '' );
JWT jwt = new JWT( 'RS256' );
jwt.pkcs8 = key;
jwt.iss = 'developer.force.com';
jwt.sub = '[email protected]'; // Update with your own email ID
jwt.aud = 'https://api.einstein.ai/v2/oauth2/token';
jwt.exp = String.valueOf(3600);
String access_token = JWTBearerFlow.getAccessToken( 'https://api.einstein.ai/v2/oauth2/token', jwt );
String keyaccess = access_token;
System.debug('******keyaccess**'+keyaccess);
Output: 18:34:11:987 USER_DEBUG [21]|DEBUG|******keyaccess**null