API Connect

 View Only
Expand all | Collapse all

How to programmatically get selected consumer organization in developer portal?

  • 1.  How to programmatically get selected consumer organization in developer portal?

    Posted Mon January 09, 2023 09:47 AM
    Hello all,

    I am customizing the 'create application' action in developer portal by enabling php module that implements the hook_form_alter of the create application form, what I need is to get the current selected consumer organization.
    For example, I need to access some variable that indicates that 'Test Org 2' is the selected organization at that moment.

    Thanks,


    ------------------------------
    Ahmed Ashraf
    ------------------------------


  • 2.  RE: How to programmatically get selected consumer organization in developer portal?

    Posted Wed January 11, 2023 11:20 AM

    Hi Ahmed, 

    followed up with our team and they have sent the following: 

    They suspect the following 2 lines will get you the outcome you are aiming for: 

     $userUtils = \Drupal::service('ibm_apim.user_utils');
        $org = $userUtils->getCurrentConsumerOrg();


    As it will return an object with the attributes of the currently selected org - e.g $org['url'] would give the url of that org.

    let me know if this works!



    ------------------------------
    Gabriel Marte Blanco
    Austin TX
    ------------------------------



  • 3.  RE: How to programmatically get selected consumer organization in developer portal?

    Posted Thu January 12, 2023 04:53 PM
    Hello Gabriel,

    That's awesome! It works perfect.

    Thanks for your support!

    ------------------------------
    Ahmed Ashraf
    ------------------------------