| @@ 267-289 (lines=23) @@ | ||
| 264 | $io = $this->io; |
|
| 265 | $httpCode = $res->info['http_code']; |
|
| 266 | ||
| 267 | if ('github' === $req->special) { |
|
| 268 | $message = "\nCould not fetch {$req->getURL()}, please create a GitHub OAuth token "; |
|
| 269 | if (404 === $httpCode) { |
|
| 270 | $message .= 'to access private repos'; |
|
| 271 | } else { |
|
| 272 | $message .= 'to go over the API rate limit'; |
|
| 273 | } |
|
| 274 | $github = new Util\GitHub($io, $this->config, null); |
|
| 275 | if ($github->authorizeOAuth($req->origin)) { |
|
| 276 | $this->_retry = true; |
|
| 277 | return; |
|
| 278 | } |
|
| 279 | if ($io->isInteractive() && |
|
| 280 | $github->authorizeOAuthInteractively($req->origin, $message)) { |
|
| 281 | $this->_retry = true; |
|
| 282 | return; |
|
| 283 | } |
|
| 284 | ||
| 285 | throw new Downloader\TransportException( |
|
| 286 | "Could not authenticate against $req->origin", |
|
| 287 | 401 |
|
| 288 | ); |
|
| 289 | } |
|
| 290 | ||
| 291 | if ('gitlab' === $req->special) { |
|
| 292 | $message = "\nCould not fetch {$req->getURL()}, enter your $req->origin credentials "; |
|
| @@ 291-313 (lines=23) @@ | ||
| 288 | ); |
|
| 289 | } |
|
| 290 | ||
| 291 | if ('gitlab' === $req->special) { |
|
| 292 | $message = "\nCould not fetch {$req->getURL()}, enter your $req->origin credentials "; |
|
| 293 | if (401 === $httpCode) { |
|
| 294 | $message .= 'to access private repos'; |
|
| 295 | } else { |
|
| 296 | $message .= 'to go over the API rate limit'; |
|
| 297 | } |
|
| 298 | $gitlab = new Util\GitLab($io, $this->config, null); |
|
| 299 | if ($gitlab->authorizeOAuth($req->origin)) { |
|
| 300 | $this->_retry = true; |
|
| 301 | return; |
|
| 302 | } |
|
| 303 | if ($io->isInteractive() && |
|
| 304 | $gitlab->authorizeOAuthInteractively($req->origin, $message)) { |
|
| 305 | $this->_retry = true; |
|
| 306 | return; |
|
| 307 | } |
|
| 308 | ||
| 309 | throw new Downloader\TransportException( |
|
| 310 | "Could not authenticate against $req->origin", |
|
| 311 | 401 |
|
| 312 | ); |
|
| 313 | } |
|
| 314 | ||
| 315 | // 404s are only handled for github |
|
| 316 | if (404 === $httpCode) { |
|