|
146 | 146 | { |
147 | 147 | "data": { |
148 | 148 | "text/plain": [ |
149 | | - "('4a862fd5d474b58cfad0e2432f47c33a2976facc', '28F1-E3A6')" |
| 149 | + "('466da70dae0a30102cd6df6436b57a6a5c58701a', 'CA0C-C4AE')" |
150 | 150 | ] |
151 | 151 | }, |
152 | 152 | "execution_count": null, |
|
189 | 189 | "name": "stdout", |
190 | 190 | "output_type": "stream", |
191 | 191 | "text": [ |
192 | | - "First copy your one-time code: 28F1-E3A6\n", |
| 192 | + "First copy your one-time code: CA0C-C4AE\n", |
193 | 193 | "Then visit https://github.com/login/device in your browser, and paste the code when prompted.\n" |
194 | 194 | ] |
195 | 195 | } |
|
302 | 302 | "# token = ghauth.wait(lambda: print('.', end=''))" |
303 | 303 | ] |
304 | 304 | }, |
| 305 | + { |
| 306 | + "cell_type": "code", |
| 307 | + "execution_count": null, |
| 308 | + "metadata": {}, |
| 309 | + "outputs": [], |
| 310 | + "source": [ |
| 311 | + "#export\n", |
| 312 | + "def github_auth_device(wb='', n_polls=9999):\n", |
| 313 | + " \"Authenticate with GitHub, polling up to `n_polls` times to wait for completion\"\n", |
| 314 | + " auth = GhDeviceAuth()\n", |
| 315 | + " print(f\"First copy your one-time code: \\x1b[33m{auth.user_code}\\x1b[m\")\n", |
| 316 | + " print(f\"Then visit {auth.verification_uri} in your browser, and paste the code when prompted.\")\n", |
| 317 | + " if not wb: wb = input(\"Shall we try to open the link for you? [y/n] \")\n", |
| 318 | + " if wb[0].lower()=='y': auth.open_browser()\n", |
| 319 | + "\n", |
| 320 | + " print(\"Waiting for authorization...\", end='')\n", |
| 321 | + " token = auth.wait(lambda: print('.', end=''), n_polls=n_polls)\n", |
| 322 | + " if not token: return print('Authentication not complete!')\n", |
| 323 | + " print(\"Authenticated with GitHub\")\n", |
| 324 | + " return token" |
| 325 | + ] |
| 326 | + }, |
| 327 | + { |
| 328 | + "cell_type": "markdown", |
| 329 | + "metadata": {}, |
| 330 | + "source": [ |
| 331 | + "When we run this we'll be shown a URL to visit and a code to enter in order to authenticate. Normally we'll be prompted to open a browser, and the function will wait for authentication to complete -- for demonstrating here we'll skip both of these steps:" |
| 332 | + ] |
| 333 | + }, |
| 334 | + { |
| 335 | + "cell_type": "code", |
| 336 | + "execution_count": null, |
| 337 | + "metadata": {}, |
| 338 | + "outputs": [ |
| 339 | + { |
| 340 | + "name": "stdout", |
| 341 | + "output_type": "stream", |
| 342 | + "text": [ |
| 343 | + "First copy your one-time code: \u001b[33mDD47-0B67\u001b[m\n", |
| 344 | + "Then visit https://github.com/login/device in your browser, and paste the code when prompted.\n", |
| 345 | + "Waiting for authorization...Authentication not complete!\n" |
| 346 | + ] |
| 347 | + } |
| 348 | + ], |
| 349 | + "source": [ |
| 350 | + "github_auth_device('n',n_polls=0)" |
| 351 | + ] |
| 352 | + }, |
305 | 353 | { |
306 | 354 | "cell_type": "markdown", |
307 | 355 | "metadata": {}, |
|
327 | 375 | "Converted 50_fullapi.ipynb.\n", |
328 | 376 | "Converted 80_tutorial_actions.ipynb.\n", |
329 | 377 | "Converted 90_build_lib.ipynb.\n", |
| 378 | + "Converted Untitled.ipynb.\n", |
| 379 | + "Converted ghapi demo.ipynb.\n", |
330 | 380 | "Converted index.ipynb.\n" |
331 | 381 | ] |
332 | 382 | } |
|
0 commit comments