PHP Curl on login.microsoftonline.com -


i trying create application uses curl authenticate in microsoft form.

my goal our internal environment log in powerbi without credentials being requested user, wrote following code:

    $headers   = array();     $headers[] = 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';     $headers[] = 'accept-encoding:gzip, deflate, br';     $headers[] = 'accept-language:en-us,en;q=0.8,es;q=0.6,pt;q=0.4';     $headers[] = 'cache-control:max-age=0';     $headers[] = 'connection:keep-alive';     $headers[] = 'content-length:1813';     $headers[] = 'content-type:application/x-www-form-urlencoded';     $headers[] = 'host:login.microsoftonline.com';     $headers[] = 'origin:https://login.microsoftonline.com';     $headers[] = 'referer:https://login.microsoftonline.com/common/oauth2/authorize?client_id=871c010f-5e61-4fb1-83ac-98610a7e9110&response_mode=form_post&response_type=code+id_token&scope=openid+profile&state=openidconnect.authenticationproperties%3detdt2db6cxkyjwurf6qbsf0o4rmcyearbafcxh-twnpvm1d8qbeplqj9ndhtji7btrifjkxm3gcnontodfek_liriy6gjw7snauhj_je0d2pescb5_q3yqkmfgzuhpwdzgn1ow&nonce=636270125908033382.odu3ntu1njatn2vkzc00otgzlwe4mzutndu4mgfmy2ewyju3ndcxnje0mdqtntrmyy00mjdilthlzdetzdiwowniodm3mzy5&site_id=500453&redirect_uri=https%3a%2f%2fapp.powerbi.com%2f%3fnosignupcheck%3d1&post_logout_redirect_uri=https%3a%2f%2fapp.powerbi.com%2f%3fnosignupcheck%3d1&resource=https%3a%2f%2fanalysis.windows.net%2fpowerbi%2fapi&nux=1&msafed=0';     $headers[] = 'upgrade-insecure-requests:1';     $headers[] = 'user-agent:mozilla/5.0 (macintosh; intel mac os x 10_12_3) applewebkit/537.36 (khtml, gecko) chrome/56.0.2924.87 safari/537.36';     $headers[] = 'cookie: ' . $web["cookies"];       $url = 'https://login.microsoftonline.com/common/login';     $poststring = "all form fields";     $ch = curl_init ($url);     curl_setopt($ch, curlopt_cookiejar, $ckfile);     curl_setopt($ch, curlopt_cookiefile, $ckfile);     curl_setopt($ch, curlopt_httpheader, $headers);     curl_setopt($ch, curlopt_returntransfer, true);     curl_setopt($ch, curlopt_ssl_verifypeer, false);     curl_setopt($ch, curlopt_verbose, true);     curl_setopt($ch, curlopt_followlocation, 1);     curl_setopt($ch, curlopt_post, 1);     curl_setopt($ch, curlopt_postfields, $poststring);      $output = curl_exec($ch);     curl_close($ch);     echo $output; 

note: $web["cookies"] comes previous request necessary cookies

when analysis of being sent when enter site , being sent curl same.

the problem curl trying connect long time , when finishes return comes empty

any ?


Comments