{"id":21076007,"url":"https://github.com/marcbperez/flask-restfuloauth2","last_synced_at":"2025-04-12T22:01:33.753Z","repository":{"id":258645054,"uuid":"88103041","full_name":"marcbperez/flask-restfuloauth2","owner":"marcbperez","description":"A Flask REST endpoint protected with OAuth2.","archived":false,"fork":false,"pushed_at":"2020-11-18T12:04:48.000Z","size":156,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-26T16:05:19.945Z","etag":null,"topics":["docker","flask","flask-restful","gradle","oauth2","python","rest"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcbperez.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-12T22:46:37.000Z","updated_at":"2024-12-25T22:43:25.000Z","dependencies_parsed_at":"2024-10-20T00:50:45.515Z","dependency_job_id":null,"html_url":"https://github.com/marcbperez/flask-restfuloauth2","commit_stats":null,"previous_names":["marcbperez/flask-restfuloauth2"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbperez%2Fflask-restfuloauth2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbperez%2Fflask-restfuloauth2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbperez%2Fflask-restfuloauth2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcbperez%2Fflask-restfuloauth2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcbperez","download_url":"https://codeload.github.com/marcbperez/flask-restfuloauth2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637780,"owners_count":21137538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","flask","flask-restful","gradle","oauth2","python","rest"],"created_at":"2024-11-19T19:26:03.028Z","updated_at":"2025-04-12T22:01:33.723Z","avatar_url":"https://github.com/marcbperez.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flask-restfuloauth2\n\nA Flask REST endpoint protected with OAuth2.\n\n## Installation\n\nStart by downloading and building the project when necessary. The following\ncommands will do the job on most Debian based Linux distributions.\n\n```bash\ngit clone https://github.com/marcbperez/flask-restfuloauth2\ncd flask-restfuloauth2\nexport FLASK_APP=\"restfuloauth2\"\nexport SECRET_KEY=\"non-production-key\"\nexport SQLALCHEMY_DATABASE_URI=\"sqlite:///db.sqlite3\"\nsudo -HE ./gradlew\n```\n\n## Usage\n\nTo start the service set the environment variables and run the Gradle wrapper as\nshown above. The Swagger manifest can be found on `http://127.0.0.1:5000` and\nits UI can be accessed via `http://127.0.0.1:5000/api`.\n\nFirst, access `http://127.0.0.1:5000/oauth/management` and create a user and api\nclient. Then use the client id, username and password to generate a bearer token.\n\n```bash\ncurl -X POST -d \\\n\"grant_type=password\u0026client_id=8diLQbKSkseuZ99Q3kwFAWugXjDvImrqTALeM7sd\\\n\u0026username=user\u0026password=pass\" \\\nhttp://127.0.0.1:5000/v1/oauth/token\n```\n\nThe bearer token can now be used to access the user's protected data.\n\n```bash\ncurl -H \"Authorization: Bearer nOVFSNUDoP2bC1ScMRuYz8zCXeTY8F\" \\\nhttp://127.0.0.1:5000/v1/oauth/check\n```\n\nThe example dummy api is protected and will need a valid user, client and bearer\ntoken. To list, add, modify and delete tasks see the script below.\n\n```bash\n# GET the dummy list.\ncurl -H \"Authorization: Bearer yIMqTV5zOGQlRpIMBMpZnyHFMR0QW3\" \\\nhttp://127.0.0.1:5000/v1/dummy\n# Paginate and sort de dummy list by ascending (asc) or descending (desc).\ncurl -H \"Authorization: Bearer yIMqTV5zOGQlRpIMBMpZnyHFMR0QW3\" \\\n\"http://127.0.0.1:5000/v1/dummy?page=1\u0026max_results=5\u0026sort=id-desc\"\n# CREATE a new dummy.\ncurl -X POST -H \"Authorization: Bearer yIMqTV5zOGQlRpIMBMpZnyHFMR0QW3\" \\\n-d \"public=0\" \\\nhttp://127.0.0.1:5000/v1/dummy\n# MODIFY a dummy stating its etag.\ncurl -X PUT -H \"Authorization: Bearer yIMqTV5zOGQlRpIMBMpZnyHFMR0QW3\" \\\n-d \"etag=rz05FPx8qOIYJdmYZNLvcWupzh9qLlSoZnphpBFC\\\n    \u0026public=1\" \\\nhttp://127.0.0.1:5000/v1/dummy/1\n# GET a dummy.\ncurl -H \"Authorization: Bearer yIMqTV5zOGQlRpIMBMpZnyHFMR0QW3\" \\\nhttp://127.0.0.1:5000/v1/dummy/1\n# DELETE a dummy stating its etag.\ncurl -X DELETE -H \"Authorization: Bearer yIMqTV5zOGQlRpIMBMpZnyHFMR0QW3\" \\\n-d \"etag=DMwVytdmg3CtwDgbm9wWOINjX73Iev2n4NFkRsV7\" \\\nhttp://127.0.0.1:5000/v1/dummy/1\n```\n\nA search operation is also available. To use it send an url-encoded JSON\n`search` parameter to an item endpoint such as `http://127.0.0.1:5000/v1/dummy`.\nValid column condition operators are `and` and `or`. As for column operators all\n `=`, `!=`, `\u003c`, `\u003c=`, `\u003e`, `\u003e=` and `like` are available.\n\n```json\n{\n  \"operator\": \"and\",\n  \"conditions\": [\n    {\n      \"column\": \"id\",\n      \"operator\": \"=\",\n      \"value\": 3\n    },\n    {\n      \"operator\": \"or\",\n      \"conditions\": [\n        {\n          \"column\": \"public\",\n          \"operator\": \"=\",\n          \"value\": 1\n        },\n        {\n          \"column\": \"etag\",\n          \"operator\": \"!=\",\n          \"value\": \"\"\n        }\n      ]\n    }\n  ]\n}\n```\n\n## Testing\n\nTest checks are executed automatically every time the project is built. Builds\ncan be done remotely or continuously on a development context. For continuous\nintegration and development use docker-compose. This is recommended to keep the\nsystem clean while the project is built every time the sources change.\n\n```bash\nsudo docker-compose up builder\n```\n\nFor continuous integration and development without any dependencies use the\nGradle wrapper. This is the best option if the wrapper is available and the\nDocker context is not valid. For a full list of tasks, see\n`sudo ./gradlew tasks --all`. For a CI cycle use `sudo ./gradlew --continuous`.\n\nFor continuous integration and development without Docker or the project wrapper\nuse Gradle directly. This will create the wrapper in case it is not present.\nSimilar to the above, for a CI cycle use `sudo gradle --continuous`. Gradle\n3.4.1 is required for this to work. Plain Docker is also available for remote\nintegration tasks and alike. Build the image with `sudo docker build .` and run\na new container with it. Information on how to install Docker and docker-compose\ncan be found in their [official page][install-docker-compose]. A similar\ninstallation guide is available [for Gradle][install-gradle].\n\n## Deployment\n\nTo deploy this service set the `SECRET_KEY` and `SQLALCHEMY_DATABASE_URI`\nDocker environment variables and run the default Dockerfile.\n\n```bash\nsudo docker-compose up runner\n```\n\n## Troubleshooting\n\nThe [issue tracker][issue-tracker] intends to manage and compile bugs,\nenhancements, proposals and tasks. Reading through its material or reporting to\nits contributors via the platform is strongly recommended.\n\n## Contributing\n\nThis project adheres to [Semantic Versioning][semver] and to certain syntax\nconventions defined in [.editorconfig][editorconfig]. To get a list of changes\nrefer to the [CHANGELOG][changelog]. Only branches prefixed by *feature-*,\n*hotfix-*, or *release-* will be considered:\n\n  - Fork the project.\n  - Create your new branch: `git checkout -b feature-my-feature develop`\n  - Commit your changes: `git commit -am 'Added my new feature.'`\n  - Push the branch: `git push origin feature-my-feature`\n  - Submit a pull request.\n\n## Credits\n\nThis project is created by [marcbperez][author] and maintained by its\n[author][author] and contributors.\n\n## License\n\nThis project is licensed under the [Apache License Version 2.0][license].\n\n[author]: https://marcbperez.github.io\n[issue-tracker]: https://github.com/marcbperez/flask-restfuloauth2/issues\n[editorconfig]: .editorconfig\n[changelog]: CHANGELOG.md\n[license]: LICENSE\n[semver]: http://semver.org\n[install-docker-compose]: https://docs.docker.com/compose/install/\n[install-gradle]: https://gradle.org/install\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcbperez%2Fflask-restfuloauth2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcbperez%2Fflask-restfuloauth2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcbperez%2Fflask-restfuloauth2/lists"}