'code', 'redirect_uri' => urlencode ( $this->getCallbackUri () ), 'client_id' => $this->getClientId (), 'client_secret' => $this->getClientSecret (), 'scope' => urlencode ( self::SCOPE ), 'access_type' => 'offline', 'approval_prompt' => 'force' ); $authUrl = $this->getAuthorizationUrl () . '?' . build_query ( $params ); $this->getLogger ()->debug ( 'Requesting verification code from Microsoft' ); PostmanUtils::redirect ( $authUrl ); } /** * ********************************************** * If we have a code back from the OAuth 2.0 flow, * we need to exchange that for an access token. * We store the resultant access token * bundle in the session, and redirect to ourself. * ********************************************** */ public function processAuthorizationGrantCode($transactionId) { if (isset ( $_GET ['code'] )) { $code = filter_input( INPUT_GET, 'code', FILTER_SANITIZE_STRING ); $this->getLogger ()->debug ( 'Found authorization code in request header' ); $postvals = array ( 'client_id' => $this->getClientId (), 'client_secret' => $this->getClientSecret (), 'grant_type' => 'authorization_code', 'redirect_uri' => $this->getCallbackUri (), 'code' => $code ); $response = PostmanUtils::remotePostGetBodyOnly ( $this->getTokenUrl (), $postvals ); $this->processResponse ( $response ); $this->getAuthorizationToken ()->setVendorName ( self::VENDOR_NAME ); return true; } else { $this->getLogger ()->debug ( 'Expected code in the request header but found none - user probably denied request' ); return false; } } public function getAuthorizationUrl() { return self::WINDOWS_LIVE_ENDPOINT; } public function getTokenUrl() { return self::WINDOWS_LIVE_REFRESH; } } }