I have created connected App using metadata API,Now I have to retrieve connected App's Information using metadata API,The code is working fine for the Apps which is created manually but not for the Apps which is created through metadata .I have provided full access for both connected Apps.

public static void retrieveConnectedApp() {
    MetadataService.MetadataPort service = new MetadataService.MetadataPort();
    service.SessionHeader = new MetadataService.SessionHeader_element();
    service.SessionHeader.sessionId = UserInfo.getSessionId();
    MetadataService.ConnectedApp connectedApp =
            (MetadataService.ConnectedApp)service.readMetadata('ConnectedApp', new String[] {'ActivePrime' }).getRecords()[0];

Is there any security issue ? For Oauth authentication, connected app (manually) is working fine but connected app (Metadata API) failed .

  • Have you define profile settings (objects accessible through connected App) for users which will be accessing data? – Rohit Mourya Feb 16 '17 at 8:55
  • Connected App is not an object itself . what profile setting I am supposed to do? – Ajay Prakash Dubey Feb 16 '17 at 10:30
  • I've already answered this question. Please visit this link – Rohit Mourya Feb 16 '17 at 10:31
  • I just went through given link . So where I can provide those permissions ? – Ajay Prakash Dubey Feb 16 '17 at 11:26
  • @AjayPrakashDubey, so a Connected App that you created in the UI is coming back with that Apex code, but not one that you created via the Metadata API? Are there any errors, or is the latter just not returning a MetadataService.ConnectedApp? – Daniel Ballinger Feb 21 '17 at 19:26

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.