function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
basha skbasha sk 

External website doesn't login ondemand through salesforce iframes?



   Hi Everyone,

    I'm trying to login external website from salesforce iframes.

     For testing I check the URL in browser like below i get the response

     URL : https://xxxxxxxx.adobeconnect.com/api/xml?action=login&login=xxxxxxx.com&password=xxxxxxx

     Response :
     ----------
      <results>
      <status code="ok"/>
      <OWASP_CSRF_TOKEN>
     <token>
                442adc814ed114ac272552be35684e1253444f5d7d5e05b2ee73d72adf287320
      </token>
    </OWASP_CSRF_TOKEN>
 </results>

now i' testing the login in same window with url : https://xxxxxxxx.adobeconnect.com/

now thios it directly opens the home page of my instance.

Now I'm doing the same process through REST api but the browser ignores the token doesn't take the login access
it just opens the login page of my instance.

This is my REST API please check it once

Apex class:
--------------

public class CreateEvent{
    public Test__c login;          
                            public CreateEvent(ApexPages.StandardSetController controller){      
       this.login= (Test__c)controller.getRecord();            
     }
       public CreateEvent(ApexPages.StandardController controller){}

       public Pagereference processCheck(){

   CreateWebinar.postfieldsFuture(username,password,url,cookie);
   PageReference pageref2 = new PageReference('/apex/AdobeIframe');
   return pageref;   

REST API
---------

global class CreateWebinar{

@future (callout=true)
global static void postfieldsFuture(String username, String password,String url,String cookie){

    getParticipants(username, password, url,cookie);
}

global static HttpResponse getParticipants(String username, String password,String url,String cookie){

    Http http = new Http();
    HttpRequest req =  new HttpRequest();         
    HttpResponse res =  new HttpResponse();         
    Blob headerValue = Blob.valueOf(username + ':' + password);
    String authorizationHeader = 'BASIC ' +
    EncodingUtil.base64Encode(headerValue);
    req.setHeader('Authorization', authorizationHeader);             
    req.setEndpoint(url+'/api/xml?action=login&login='+username+'&password='+password+'&domain=acme.adobe.com&session='+cookie);
    req.setMethod('GET');
    req.setHeader('Content-Type', 'application/json');
    req.setHeader('Accept','application/json');
    res = http.send(req);
    String[] headerkeys = res.getHeaderKeys();
    Map<string, string> headers = new map<string, string>();
    for(string s : headerkeys){
        headers.put(s,res.getHeader(s));
           system.debug('header: ' + s + ' value: ' + res.getHeader(s));
    }

    //HeaderValues:======(Server, Cache-Control, Connection, Set-Cookie, Expires, Content-Length, Date, Content-Type)
    System.debug('HeaderValues:======'+headerkeys);
    System.debug('MyResult == :'+res.getBody());       

    }
}

Adobe Iframe
----------------
<apex:page>
    <apex:iframe height="800" width="1230" src="https://meet30705009.adobeconnect.com?domain=acme.adobeconnect.com&Set-Cookie=apac1breeztxw8g5cx2g4x8wh6" scrolling="true"/>
</apex:page>



how to login to my instance ondemand through iframes please check it once

if anyone having idea please let me know

Thanks
Basha
NagendraNagendra (Salesforce Developers) 
Hi Basha,

Based on your description there is almost certainly a session cookie involved in the authentication process.

When you make the direct request to the browser the resulting cookie will be kept for subsequent requests.

However, when you make the direct HTTP call from Apex the resulting cookie will be ignored.

Check the HttpResponse.getHeaderKeys() for the cookie that comes back.
Now you have the cookie you will need to make all subsequent requests from Apex as well as you won't be able to set a browser cookie in the *.adobeconnect.com domain from Salesforce.

Hope this helps.

Kindly mark this as solved if the information was helpful.

Thanks,
Nagendra
basha skbasha sk
@Nagendra thanks for giving the response I'm getting the retur cookie value by using the below code


String[] headerkeys = res.getHeaderKeys();
    Map<string, string> headers = new map<string, string>();
    for(string s : headerkeys){
        headers.put(s,res.getHeader(s));
           system.debug('header: ' + s + ' value: ' + res.getHeader(s));
    }

Please  chekc my REST API I'm getting the return cookiw value but how can I use this for login attempt further.please help i tried this from last three days.Thanks