{ "info": { "author": "Koen Vossen", "author_email": "koen.vossen@citylive.be", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "===============================\nMobile Vikings OAuth API Client\n===============================\n\n.. contents::\n\n\nOverview\n========\n\nOAuth is an authorization protocol that allows applications (a balance checker\non your Android phone, for example) to consume user data from a service\nprovider (the Mobile Vikings API) data without having to know the user's\ncredentials. The ``mvoauthapi`` package contains a client for the Mobile\nVikings API with OAuth support.\n\n\nInstallation\n============\n\nRun the following command in the directory containing this ``README`` file::\n\n python setup.py install\n\n\nCalling the Mobile Vikings API\n==============================\n\nThe ``call.py`` file contains a sample implementation that calls the Mobile\nVikings API using the OAuth client. To request the balance on a SIM card,\nfor example, execute the following command::\n\n python call.py sim_balance add_price_plan=1\n\nYou will be prompted for a consumer key and secret. These credentials can be\nfound on your Mobile Vikings `account settings page`_.\n\n.. _`account settings page`: https://mobilevikings.com/account/settings/\n\nVisit the `API documentation`_ page for an overview of the available methods\nand their arguments.\n\n.. _`API documentation`: http://mobilevikings.com/api/2.0/doc/\n\nIf the `xAuth extension`_ has been enabled for your consumer, you can test it by\npassing the ``-x`` option to ``call.py``. You will be prompted for an account's\nusername and password instead of being redirected to the Mobile Vikings site.\nNote that xAuth is not enabled by default. If you're developing a mobile app\nand want to use it, email us at mailto:info@mobilevikings.com.\n\n.. _`xAuth extension`: https://dev.twitter.com/docs/oauth/xauth\n\n``call.py`` will store your consumer credentials and tokens in\n``~/.mvoauthapi.cfg`` so you don't have to re-enter your data and go through\nthe access token request process each time you make a call.\n\n\nUsing the client in your application\n====================================\n\nAcquiring an access token\n-------------------------\n\nThe OAuth protocol implements authorization by exchanging tokens. First, the\napplication fetches a request token with a given callback URL. Using this\ntoken, it can redirect the user to an authorization URL on the Mobile Vikings\nsite. On this page, the user is asked if she wants to grant permission to the\napplication. If she does, she is redirected to the callback URL that now\ncontains a verification code. The application can then use the verification\ncode to request an access token. With this access token, the API calls can\nfinally be made.\n\n::\n\n from mvoauthapi.client import ApiClient, Token\n api = ApiClient(consumer_key, consumer_secret)\n api.fetch_request_token(callback='http://my-app.com/access_granted')\n url = api.make_authorization_url()\n\nNow, redirect the user to the authorization URL. If she accepts, she will be\nredirected to the ``access_granted`` page of your site. There will be\n``oauth_verifier`` and ``oauth_token`` GET query parameters present in the URL.\nPass them to the client and fetch the access token.\n\n::\n\n request_key = request.GET['oauth_token']\n request_secret = '' # Fetch this from your session or db.\n verifier = request.GET['oauth_verifier']\n request_token = Token(request_key, request_secret)\n request_token.set_verifier(verifier)\n api = ApiClient(consumer_key, consumer_secret)\n api.set_request_token(request_token)\n access_token = api.fetch_access_token()\n\nYou can now use the ``api`` object to make calls.\n\n::\n\n api.get('top_up_history')\n\nNote: if you don't want to use a redirect to your application's site, omit the\n``callback`` argument in the ``fetch_request_token`` call. The Mobile Vikings\nAPI will then display the verification code to the user when access has been\ngranted.\n\nUsing the xAuth extension\n-------------------------\n\nSimply call ``fetch_access_token_via_xauth()`` after initializing the\nclient. It is imperative that you do *not* store the user's credentials. Use\nthem once to request the access token and discard them afterwards. From then\non, use the access token to make calls.\n\n::\n\n api = ApiClient(consumer_key, consumer_secret)\n api.fetch_access_token_via_xauth(username, password)\n api.get('sim_balance')\n\n\nRe-using an existing access token\n---------------------------------\n\nYour application can re-use the access token once it has been acquired; you\nneed not go through the authorization process again. The token will stay valid\nuntil the user revokes it.\n\n::\n\n api = ApiClient(consumer_key, consumer_secret)\n api.set_access_token(access_token)\n api.get('sim_balance')\n\n\nSupport\n=======\n\nIf you have questions, comments or suggestions, pay a visit to the `Mobile\nVikings API users group`_.\n\n.. _`Mobile Vikings API users group`: http://groups.google.com/group/mobile-vikings-api-users\n\n\n.. vim: tw=79", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/kvsn/mvoauthapi", "keywords": "mobile vikings oauth api client", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "mvoauthapi", "package_url": "https://pypi.org/project/mvoauthapi/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/mvoauthapi/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/kvsn/mvoauthapi" }, "release_url": "https://pypi.org/project/mvoauthapi/0.2/", "requires_dist": null, "requires_python": null, "summary": "Mobile Vikings OAuth API Client", "version": "0.2" }, "last_serial": 1063624, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "908c83751d4c75c94b0090e003254f84", "sha256": "74e22ded75b1faf1bca230a1831d576e770e4b63237f9d222e39b294ce253799" }, "downloads": -1, "filename": "mvoauthapi-0.2.tar.gz", "has_sig": false, "md5_digest": "908c83751d4c75c94b0090e003254f84", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5900, "upload_time": "2014-04-17T16:14:19", "url": "https://files.pythonhosted.org/packages/b8/0f/d06db496e435a1013e11be3189f10bd7c2078906a851934a7f5096243fd9/mvoauthapi-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "908c83751d4c75c94b0090e003254f84", "sha256": "74e22ded75b1faf1bca230a1831d576e770e4b63237f9d222e39b294ce253799" }, "downloads": -1, "filename": "mvoauthapi-0.2.tar.gz", "has_sig": false, "md5_digest": "908c83751d4c75c94b0090e003254f84", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5900, "upload_time": "2014-04-17T16:14:19", "url": "https://files.pythonhosted.org/packages/b8/0f/d06db496e435a1013e11be3189f10bd7c2078906a851934a7f5096243fd9/mvoauthapi-0.2.tar.gz" } ] }