function getAuthorizationCode($client) { \ProcessMaker\Services\OAuth2\Server::setDatabaseSource(getDsn()); \ProcessMaker\Services\OAuth2\Server::setPmClientId($client['CLIENT_ID']); $oauthServer = new \ProcessMaker\Services\OAuth2\Server(); $userId = $_SESSION['USER_LOGGED']; $authorize = true; $_GET = array_merge($_GET, array( 'response_type' => 'code', 'client_id' => $client['CLIENT_ID'], 'scope' => implode(' ', $oauthServer->getScope()) )); $response = $oauthServer->postAuthorize($authorize, $userId, true); $code = substr($response->getHttpHeader('Location'), strpos($response->getHttpHeader('Location'), 'code=')+5, 40); return $code; }
/** * Gets the PDO object for database acccess * * @return PDO */ function getPDO() { return new PDO(getDsn()); }