1

I am trying to integrate Salesforce with Jira using a Named Credential and oAuth 2.0. The Named Credential requires a Custom Auth. Provider which requires an AuthProviderPluginClass. The authentication and authorization are working fine, and everything for the named credential appears to be stored as expected.

The hiccup here is that making requests with oAuth requires a cloudId (issued by Jira) to be passed as part of the request URL. I can get the cloudId for the authenticating user and use that to make additional requests while I'm still in the AuthProviderPluginClass, but any attempt to persist the cloudId has been met with failure. I can see the cloudId and UserId in the debug logs, but no matter what I do I can't seem to save the cloudId seemingly because the AuthProviderPluginClass is 'swallowing' everything.

I have tried:

  1. Updating the User record using DML. I can see the DML_OPERATION line in the debug log, but the field on the User remains blank.
  2. Updating the User record using DML in a @future method. In this case I can see the METHOD_ENTRY line in the debug log, but no futureHandler log ever gets created and the field on the User remains blank.
  3. Adding a cloudId field to the Custom Metadata driving the Auth. Provider, using Apex's Metadata class to deploy the cloudId when I retrieve it from Jira. This works when I run the code in the Execute Anonymous window, and once again I can see the METHOD_ENTRY debug line when I call the code from within the AuthProviderPluginClass, but no deployment job gets created when the method is called this way.

I am aware that Jira supports basic authentication with UserName and Password, but since this is being deprecated and the integration I'm building is for an AppExchange package, I'd really like to get the oAuth flow working. Any tips on how to persist the cloudId would be appreciated.

  • That is odd. Can you post some of the code you've tried? Curious to get a look at this. – Shane Steinfeld Sep 27 '18 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.