|
29 | 29 | },
|
30 | 30 | {
|
31 | 31 | "cell_type": "code",
|
32 |
| - "execution_count": 1, |
33 |
| - "metadata": { |
34 |
| - "collapsed": true |
35 |
| - }, |
| 32 | + "execution_count": 3, |
| 33 | + "metadata": {}, |
36 | 34 | "outputs": [],
|
37 | 35 | "source": [
|
38 | 36 | "# import the GIS class in gis module\n",
|
|
474 | 472 | "## Storing your credentialls locally\n",
|
475 | 473 | "If you are signing in frequently to a particular GIS and would like to store the credentials locally on your computer, then you could do so using the `profile` parameter of your `GIS`.\n",
|
476 | 474 | "\n",
|
477 |
| - "<blockquote>\n", |
478 |
| - "This persisted profile for the GIS is stored in the users home directory in a config file named .arcgisprofile. The profile is <b>NOT ENCRYPTED</b> and you need to take care to protect the saved profile using operating system security or by other means. Once a profile has been saved, passing the profile parameter by itself uses the authorization credentials saved in the configuration file.\n", |
479 |
| - "</blockquote>" |
| 475 | + "Persistent profiles for the GIS can be created by giving the GIS authorization credentials and specifying a profile name. The profile stores all of the authorization credentials (except the password) in the user’s home directory in an unencrypted config file named `.arcgisprofile.` The profile securely stores the password in an O.S. specific password manager through the [keyring](https://pypi.python.org/pypi/keyring) python module. (Note: Linux systems may need additional software installed and configured for proper security) Once a profile has been saved, passing the profile parameter by itself uses the authorization credentials saved in the configuration file/password manager by that profile name. Multiple profiles can be created and used in parallel.\n" |
480 | 476 | ]
|
481 | 477 | },
|
482 | 478 | {
|
483 | 479 | "cell_type": "code",
|
484 |
| - "execution_count": 23, |
| 480 | + "execution_count": 4, |
485 | 481 | "metadata": {},
|
486 | 482 | "outputs": [
|
487 | 483 | {
|
488 | 484 | "name": "stdout",
|
489 | 485 | "output_type": "stream",
|
490 | 486 | "text": [
|
491 |
| - "Successfully logged in as: arcgis_python\n" |
| 487 | + "profile defined for GIS @ https://python.playground.esri.com/portal\n", |
| 488 | + "profile defined for GIS @ https://geosaurus.maps.arcgis.com\n" |
492 | 489 | ]
|
493 | 490 | }
|
494 | 491 | ],
|
495 | 492 | "source": [
|
496 |
| - "gis = GIS(\"https://python.playground.esri.com/portal\", username='arcgis_python', password='amazing_arcgis_123',\n", |
497 |
| - " profile='python_playground_prof')\n", |
498 |
| - "\n", |
499 |
| - "print(\"Successfully logged in as: \" + gis.properties.user.username)" |
| 493 | + "#Define 2 different profiles for two different urls\n", |
| 494 | + "playground_gis = GIS(url=\"https://python.playground.esri.com/portal\", username='arcgis_python', password='amazing_arcgis_123',\n", |
| 495 | + " profile='python_playground_prof')\n", |
| 496 | + "agol_gis = GIS(url=\"https://arcgis.com/\", username='arcgis_python', password=\"P@ssword123\",\n", |
| 497 | + " profile=\"AGOL_prof\")\n", |
| 498 | + "print(\"profile defined for {}\".format(playground_gis))\n", |
| 499 | + "print(\"profile defined for {}\".format(agol_gis))" |
500 | 500 | ]
|
501 | 501 | },
|
502 | 502 | {
|
503 | 503 | "cell_type": "markdown",
|
504 | 504 | "metadata": {},
|
505 | 505 | "source": [
|
506 |
| - "To sign in during a different session, simply specify the profile file name." |
| 506 | + "To sign in during a different session, simply specify the profile file name. You can work with any number of connections concurrently, as the authentication credentials stored for each profile will be automatically loaded at runtime." |
507 | 507 | ]
|
508 | 508 | },
|
509 | 509 | {
|
510 | 510 | "cell_type": "code",
|
511 |
| - "execution_count": 24, |
| 511 | + "execution_count": 21, |
512 | 512 | "metadata": {},
|
513 | 513 | "outputs": [
|
514 | 514 | {
|
515 | 515 | "name": "stdout",
|
516 | 516 | "output_type": "stream",
|
517 | 517 | "text": [
|
518 |
| - "Successfully logged in as: arcgis_python\n" |
| 518 | + "Successfully logged into 'python.playground.esri.com/portal' via the 'arcgis_python' user\n", |
| 519 | + "Successfully logged into 'www.arcgis.com' via the 'arcgis_python' user\n" |
519 | 520 | ]
|
520 | 521 | }
|
521 | 522 | ],
|
522 | 523 | "source": [
|
523 |
| - "gis2 = GIS(profile='python_playground_prof')\n", |
524 |
| - "print(\"Successfully logged in as: \" + gis2.properties.user.username)" |
| 524 | + "def print_profile_info(gis):\n", |
| 525 | + " print(\"Successfully logged into '{}' via the '{}' user\".format(\n", |
| 526 | + " gis.properties.portalHostname,\n", |
| 527 | + " gis.properties.user.username)) \n", |
| 528 | + "\n", |
| 529 | + "playground_gis = GIS(profile='python_playground_prof')\n", |
| 530 | + "print_profile_info(playground_gis)\n", |
| 531 | + "\n", |
| 532 | + "agol_gis = GIS(profile=\"AGOL_prof\")\n", |
| 533 | + "print_profile_info(agol_gis)" |
| 534 | + ] |
| 535 | + }, |
| 536 | + { |
| 537 | + "cell_type": "markdown", |
| 538 | + "metadata": {}, |
| 539 | + "source": [ |
| 540 | + "### Persistent profiles details\n", |
| 541 | + "Persistent profiles will store the any combination of the following ```GIS()``` parameters in the unencrypted `.arcgisprofile` file: \n", |
| 542 | + "* ```url```\n", |
| 543 | + "* ```username```\n", |
| 544 | + "* ```key_file```\n", |
| 545 | + "* ```cert_file```\n", |
| 546 | + "* ```client_id```\n", |
| 547 | + "\n", |
| 548 | + "The ```password``` parameter (if specified) will be securely stored through the [keyring](https://pypi.python.org/pypi/keyring) module. This means that, behind the scenes, your password is retrieved at run-time from an operating system specific password store.\n", |
| 549 | + "\n", |
| 550 | + "### Windows\n", |
| 551 | + "\n", |
| 552 | + "On Windows, your password will be stored in the Windows Credentials Manager. You can access the Credentials Manager to manage stored passwords by selecting:\n", |
| 553 | + "> Start > Control Panel > User Accounts > Credential Manager > Windows Credentials > Generic Credentials\n", |
| 554 | + "\n", |
| 555 | + "If you had a password stored through a profile named \"profile_example\", you would see this entry under \"arcgis_python_api_profile_passwords\":\n", |
| 556 | + "\n", |
| 557 | + "\n", |
| 558 | + "\n", |
| 559 | + "Notice that in the Windows Credentials Manager's view, the profile name \"profile_example\" is filed under \"User name\".\n", |
| 560 | + "\n", |
| 561 | + "### macOS\n", |
| 562 | + "\n", |
| 563 | + "On macOS, your password will be stored in Keychain Access. You can access the Keychain to manage stored passwords by selecting:\n", |
| 564 | + "\n", |
| 565 | + "> Applications > Utilities > Keychain Access > Passwords > \"arcgis_python_api_profile_passwords\"\n", |
| 566 | + "\n", |
| 567 | + "### Linux\n", |
| 568 | + "\n", |
| 569 | + "On Linux, you may need additional software installed and configured to securely store passwords with persistent profiles. The Python executable running must have access over ```dbus``` to any of the following:\n", |
| 570 | + "\n", |
| 571 | + "* ```Freedesktop Secret Service``` / ```secretstorage``` for a GNOME environment\n", |
| 572 | + "* ```KWallet``` for a KDE environment\n", |
| 573 | + "* A custom configuration of the previous software packages and ```gnome-key-ring``` for a [headless environment](https://pypi.python.org/pypi/keyring#using-keyring-on-headless-linux-systems).\n", |
| 574 | + "\n", |
| 575 | + "Conda cannot use the ```dbus``` python module required for this, so it is best to install the ```arcgis``` package through the system-level python and pip. Read more about how to configure keyring on linux [on the keyring doc page](https://pypi.python.org/pypi/keyring#linux)." |
525 | 576 | ]
|
526 | 577 | }
|
527 | 578 | ],
|
528 | 579 | "metadata": {
|
529 | 580 | "anaconda-cloud": {},
|
530 | 581 | "kernelspec": {
|
531 |
| - "display_name": "Python [default]", |
| 582 | + "display_name": "Python 3", |
532 | 583 | "language": "python",
|
533 | 584 | "name": "python3"
|
534 | 585 | },
|
|
542 | 593 | "name": "python",
|
543 | 594 | "nbconvert_exporter": "python",
|
544 | 595 | "pygments_lexer": "ipython3",
|
545 |
| - "version": "3.5.2" |
| 596 | + "version": "3.6.4" |
546 | 597 | }
|
547 | 598 | },
|
548 | 599 | "nbformat": 4,
|
|
0 commit comments