/** * Computes the login URL for redirection. * * @param string $destinationURL The desired final destination URL for the * user once login is complete. If 'destinationURL' does not * have a host specified, we will use the host from the * current request. * * @param string $federatedIdentity The parameter is used to trigger OpenId * Login flow, an empty value will trigger Google OpenID Login * by default. * * @return string Login URL. If federatedIdentity is set, this will be * a federated login using the specified identity. If not, this * will use Google Accounts. */ public static function createLoginURL($destinationURL = null, $authDomain = null, $federatedIdentity = null) { $req = new CreateLoginURLRequest(); $resp = new CreateLoginURLResponse(); if ($destinationURL !== null) { $req->setDestinationUrl($destinationURL); } else { $req . setDestinationUrl(''); } if ($authDomain !== null) { $req->setAuthDomain($authDomain); } if ($federatedIdentity !== null) { $req->setFederatedIdentity($federatedIdentity); } try { ApiProxy::makeSyncCall('user', 'CreateLoginURL', $req, $resp); } catch (ApplicationError $e) { if ($e->getApplicationError() === ErrorCode::REDIRECT_URL_TOO_LONG) { throw new RedirectTooLongError(); } elseif ($e->getApplicationError() === ErrorCode::NOT_ALLOWED) { throw new NotAllowedError(); } else { throw $e; } } return $resp->getLoginUrl(); }
/** * Computes the login URL for redirection. * * @param string $destination_url The desired final destination URL for the * user once login is complete. If 'destinationURL' does not * have a host specified, we will use the host from the * current request. * * @param string $federated_identity The parameter is used to trigger OpenId * Login flow, an empty value will trigger Google OpenID Login * by default. * * @return string Login URL. If federatedIdentity is set, this will be * a federated login using the specified identity. If not, this * will use Google Accounts. * * @throws UsersException If there was a problem using the Users service. */ public static function createLoginURL($destination_url = null, $federated_identity = null) { $req = new CreateLoginURLRequest(); $resp = new CreateLoginURLResponse(); if ($destination_url !== null) { $req->setDestinationUrl($destination_url); } else { $req->setDestinationUrl(''); } if ($federated_identity !== null) { $req->setFederatedIdentity($federated_identity); } try { ApiProxy::makeSyncCall('user', 'CreateLoginURL', $req, $resp); } catch (ApplicationError $e) { throw self::applicationErrorToException($e, htmlspecialchars($destination_url)); } return $resp->getLoginUrl(); }