{"id":15059025,"url":"https://github.com/myConsciousness/mastodon-oauth2","last_synced_at":"2025-08-29T09:31:48.589Z","repository":{"id":63347025,"uuid":"567116155","full_name":"myConsciousness/mastodon-oauth2","owner":"myConsciousness","description":"This library provides the optimized and easiest way to authenticate with Mastodon's OAuth 2.0  in your Flutter app 🎯","archived":false,"fork":false,"pushed_at":"2024-11-02T08:50:40.000Z","size":366,"stargazers_count":16,"open_issues_count":5,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-24T18:46:47.402Z","etag":null,"topics":["dart","flutter","mastodon","mastodon-api","oauth","oauth2","oauth2-authentication","oauth2-client"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/mastodon_oauth2","language":"C++","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/myConsciousness.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["myConsciousness"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-11-17T05:14:25.000Z","updated_at":"2024-11-30T08:32:41.000Z","dependencies_parsed_at":"2023-11-09T18:04:10.992Z","dependency_job_id":"904f1c39-352b-4115-bce8-4bac8551b05a","html_url":"https://github.com/myConsciousness/mastodon-oauth2","commit_stats":{"total_commits":31,"total_committers":5,"mean_commits":6.2,"dds":0.5161290322580645,"last_synced_commit":"05b7c2b90c6de75b7da30c471f51d15a9e5f39e4"},"previous_names":["myconsciousness/mastodon-oauth2","mastodon-dart/mastodon-oauth2"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myConsciousness%2Fmastodon-oauth2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myConsciousness%2Fmastodon-oauth2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myConsciousness%2Fmastodon-oauth2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myConsciousness%2Fmastodon-oauth2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myConsciousness","download_url":"https://codeload.github.com/myConsciousness/mastodon-oauth2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231352266,"owners_count":18363523,"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":["dart","flutter","mastodon","mastodon-api","oauth","oauth2","oauth2-authentication","oauth2-client"],"created_at":"2024-09-24T22:35:38.810Z","updated_at":"2024-12-26T12:11:57.425Z","avatar_url":"https://github.com/myConsciousness.png","language":"C++","funding_links":["https://github.com/sponsors/myConsciousness","https://github.com/sponsors/myconsciousness"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/mastodon-dart/mastodon-oauth2\"\u003e\n    \u003cimg alt=\"mastodon_oauth2\" width=\"500px\" src=\"https://user-images.githubusercontent.com/13072231/202434467-6efce2ed-83e3-4975-b21c-6388fe51c820.png\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cb\u003eThe Optimized and Easiest Way to Integrate OAuth 2.0 with Mastodon API in Flutter 🎯\u003c/b\u003e\n\u003c/p\u003e\n\n---\n\n[![GitHub Sponsor](https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=ff69b4)](https://github.com/sponsors/myConsciousness)\n[![GitHub Sponsor](https://img.shields.io/static/v1?label=Maintainer\u0026message=myConsciousness\u0026logo=GitHub\u0026color=00acee)](https://github.com/myConsciousness)\n\n[![pub package](https://img.shields.io/pub/v/mastodon_oauth2.svg?logo=dart\u0026logoColor=00b9fc)](https://pub.dartlang.org/packages/mastodon_oauth2)\n[![Dart SDK Version](https://badgen.net/pub/sdk-version/mastodon_oauth2)](https://pub.dev/packages/mastodon_oauth2/)\n[![Test](https://github.com/mastodon-dart/mastodon-oauth2/actions/workflows/test.yml/badge.svg)](https://github.com/mastodon-dart/mastodon-oauth2/actions/workflows/test.yml)\n[![Analyzer](https://github.com/mastodon-dart/mastodon-oauth2/actions/workflows/analyzer.yml/badge.svg)](https://github.com/mastodon-dart/mastodon-oauth2/actions/workflows/analyzer.yml)\n[![Issues](https://img.shields.io/github/issues/mastodon-dart/mastodon-oauth2?logo=github\u0026logoColor=white)](https://github.com/mastodon-dart/mastodon-oauth2/issues)\n[![Pull Requests](https://img.shields.io/github/issues-pr/mastodon-dart/mastodon-oauth2?logo=github\u0026logoColor=white)](https://github.com/mastodon-dart/mastodon-oauth2/pulls)\n[![Stars](https://img.shields.io/github/stars/mastodon-dart/mastodon-oauth2?logo=github\u0026logoColor=white)](https://github.com/mastodon-dart/mastodon-oauth2)\n[![Code size](https://img.shields.io/github/languages/code-size/mastodon-dart/mastodon-oauth2?logo=github\u0026logoColor=white)](https://github.com/mastodon-dart/mastodon-oauth2)\n[![Last Commits](https://img.shields.io/github/last-commit/mastodon-dart/mastodon-oauth2?logo=git\u0026logoColor=white)](https://github.com/mastodon-dart/mastodon-oauth2/commits/main)\n[![License](https://img.shields.io/github/license/mastodon-dart/mastodon-oauth2?logo=open-source-initiative\u0026logoColor=green)](https://github.com/mastodon-dart/mastodon-oauth2/blob/main/LICENSE)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](https://github.com/mastodon-dart/mastodon-oauth2/blob/main/CODE_OF_CONDUCT.md)\n\n---\n\n\u003c!-- TOC --\u003e\n\n- [1. Guide 🌎](#1-guide-)\n  - [1.1. Getting Started ⚡](#11-getting-started-)\n    - [1.1.1. Install Library](#111-install-library)\n    - [1.1.2. Import](#112-import)\n    - [1.1.3. Setup](#113-setup)\n      - [1.1.3.1. Android](#1131-android)\n      - [1.1.3.2. iOS](#1132-ios)\n      - [1.1.3.3. Web](#1133-web)\n    - [1.1.4. Implementation](#114-implementation)\n  - [1.2. Contribution 🏆](#12-contribution-)\n  - [1.3. Contributors ✨](#13-contributors-)\n  - [1.4. Support ❤️](#14-support-️)\n  - [1.5. License 🔑](#15-license-)\n  - [1.6. More Information 🧐](#16-more-information-)\n\n\u003c!-- /TOC --\u003e\n\n# 1. Guide 🌎\n\nThis library provides the easiest way to authenticate with [OAuth 2.0](https://docs.joinmastodon.org/methods/apps/oauth/) for [Mastodon API](https://docs.joinmastodon.org/client/intro/) in **Flutter** apps.\n\n**Show some ❤️ and star the repo to support the project.**\n\n## 1.1. Getting Started ⚡\n\n### 1.1.1. Install Library\n\n```bash\n flutter pub add mastodon_oauth2\n```\n\n### 1.1.2. Import\n\n```dart\nimport 'package:mastodon_oauth2/mastodon_oauth2.dart';\n```\n\n### 1.1.3. Setup\n\n#### 1.1.3.1. Android\n\nOn Android you must first set the minSdkVersion in the ***build.gradle*** file:\n\n```gradle\ndefaultConfig {\n   ...\n   minSdkVersion 18\n   ...\n```\n\nThen, to test with this library, let's set `org.example.oauth://callback/` as a callback URI in your `developer page`.\n\nYou can see `developer page` of mastodon in the link like below.\n\n- https://mastodon.instance/settings/applications\n\nAnd then, specify your `redirect uri` like below.\n\n![Set Callback URI](https://user-images.githubusercontent.com/13072231/216985941-5b4f8f3f-03c9-4807-b961-070b9f4f2b65.png)\n\nAlso it's necessary to add the following definitions to `AndroidManifest.xml`.\n\n```xml\n\u003cactivity android:name=\"com.linusu.flutter_web_auth_2.CallbackActivity\" android:exported=\"true\"\u003e\n    \u003cintent-filter android:label=\"flutter_web_auth_2\"\u003e\n        \u003caction android:name=\"android.intent.action.VIEW\" /\u003e\n        \u003ccategory android:name=\"android.intent.category.DEFAULT\" /\u003e\n        \u003ccategory android:name=\"android.intent.category.BROWSABLE\" /\u003e\n        \u003cdata android:scheme=\"org.example.oauth\" android:host=\"callback\" /\u003e\n    \u003c/intent-filter\u003e\n\u003c/activity\u003e\n```\n\nFinally you need to set this redirect url for `MastodonOAuth2Client`.\n\n```dart\nfinal oauth2 = MastodonOAuth2Client(\n  // Specify mastodon instance like \"mastodon.social\"\n  instance: 'MASTODON_INSTANCE'\n  clientId: 'YOUR_CLIENT_ID',\n  clientSecret: 'YOUR_CLIENT_SECRET',\n  redirectUri: 'org.example.oauth://callback/',\n  customUriScheme: 'org.example.oauth',\n);\n```\n\nYou can see details [here](https://github.com/mastodon-dart/mastodon-oauth2/blob/main/example/android/app/src/main/AndroidManifest.xml).\n\n#### 1.1.3.2. iOS\n\nOn iOS you need to set the platform in the ***ios/Podfile*** file:\n\n```profile\nplatform :ios, '11.0'\n```\n\nThe usage of `MastodonOAuth2Client` is the same as for Android above.\n\n#### 1.1.3.3. Web\n\nFor Web, the implementation method for using this package is the same as for `Android` and `iOS` above, but it's necessary to separately create HTML for the destination to be redirected to after authentication.\n\nFirst, you will need to create the following HTML directly under your `web` folder in preparation for OAuth authentication in your web browser. Then, let's save this HTML file with the name `auth.html`.\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003ctitle\u003eAuthentication complete\u003c/title\u003e\n\u003cp\u003e\n  Authentication is complete. If this does not happen automatically, please\n  close the window.\n  \u003cscript\u003e\n    window.opener.postMessage(window.location.href, window.location.origin);\n    window.close();\n  \u003c/script\u003e\n\u003c/p\u003e\n```\n\nAnd now your `web` folder should look like [this](https://github.com/mastodon-dart/mastodon-oauth2/tree/main/example/web).\n\n![Set auth.html](https://user-images.githubusercontent.com/13072231/216907094-56a44873-c7fb-435b-bac7-060fa34c6ed0.png)\n\nAnd then, unlike Android and iOS, the redirect URL should refer to this created `auth.html`. So, now let's set it to `http://localhost:5555/auth.html` for example.\n\n![Set redirect uri for Web](https://user-images.githubusercontent.com/13072231/216907843-12132c37-dde0-403f-8d58-27d0dc134a8c.png)\n\nFinally, you need to set this redirect url for `MastodonOAuth2Client`.\n\n```dart\nfinal oauth2 = MastodonOAuth2Client(\n  // Specify mastodon instance like \"mastodon.social\"\n  instance: 'MASTODON_INSTANCE'\n  clientId: 'YOUR_CLIENT_ID',\n  clientSecret: 'YOUR_CLIENT_SECRET',\n  redirectUri: 'http://localhost:5555/auth.html',\n  customUriScheme: 'http://localhost:5555/auth.html',\n);\n```\n\n### 1.1.4. Implementation\n\nNow all that's left is to launch the following example Flutter app and press the button to start the authentication process with **OAuth 2.0**!\n\nAfter pressing the `Authorize` button, a redirect will be performed and you will see that you have obtained your `bearer token`.\n\n```dart\nimport 'package:flutter/material.dart';\n\nimport 'package:mastodon_oauth2/mastodon_oauth2.dart';\n\nvoid main() {\n  runApp(const MaterialApp(home: Example()));\n}\n\nclass Example extends StatefulWidget {\n  const Example({Key? key}) : super(key: key);\n\n  @override\n  State\u003cExample\u003e createState() =\u003e _ExampleState();\n}\n\nclass _ExampleState extends State\u003cExample\u003e {\n  String? _accessToken;\n  String? _refreshToken;\n\n  @override\n  Widget build(BuildContext context) =\u003e Scaffold(\n        body: Center(\n          child: Column(\n            mainAxisAlignment: MainAxisAlignment.center,\n            crossAxisAlignment: CrossAxisAlignment.center,\n            children: [\n              Text('Access Token: $_accessToken'),\n              ElevatedButton(\n                onPressed: () async {\n                  final oauth2 = MastodonOAuth2Client(\n                    // Specify mastodon instance like \"mastodon.social\"\n                    instance: 'MASTODON_INSTANCE'\n                    clientId: 'YOUR_CLIENT_ID',\n                    clientSecret: 'YOUR_CLIENT_SECRET',\n\n                    // Replace redirect url as you need.\n                    redirectUri: 'org.example.oauth://callback/',\n                    customUriScheme: 'org.example.oauth',\n                  );\n\n                  final response = await oauth2.executeAuthCodeFlow(\n                    scopes: [\n                      Scope.read,\n                      Scope.write,\n                    ],\n                  );\n\n                  super.setState(() {\n                    _accessToken = response.accessToken;\n                  });\n                },\n                child: const Text('Push!'),\n              )\n            ],\n          ),\n        ),\n      );\n}\n```\n\n## 1.2. Contribution 🏆\n\nIf you would like to contribute to `mastodon-oauth2`, please create an [issue](https://github.com/mastodon-dart/mastodon-oauth2/issues) or create a Pull Request.\n\nThere are many ways to contribute to the OSS. For example, the following subjects can be considered:\n\n- There are scopes that are not implemented.\n- Documentation is outdated or incomplete.\n- Have a better way or idea to achieve the functionality.\n- etc...\n\nYou can see more details from resources below:\n\n- [Contributor Covenant Code of Conduct](https://github.com/mastodon-dart/mastodon-oauth2/blob/main/CODE_OF_CONDUCT.md)\n- [Contribution Guidelines](https://github.com/mastodon-dart/mastodon-oauth2/blob/main/CONTRIBUTING.md)\n- [Style Guide](https://github.com/mastodon-dart/mastodon-oauth2/blob/main/STYLEGUIDE.md)\n\nOr you can create a [discussion](https://github.com/mastodon-dart/mastodon-oauth2/discussions) if you like.\n\n**Feel free to join this development, diverse opinions make software better!**\n\n## 1.3. Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\" valign=\"top\" width=\"20%\"\u003e\u003ca href=\"http://shinyakato.dev\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/13072231?v=4?s=100\" width=\"100px;\" alt=\"Shinya Kato / 加藤 真也\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eShinya Kato / 加藤 真也\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/mastodon-dart/mastodon-oauth2/commits?author=myConsciousness\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/mastodon-dart/mastodon-oauth2/commits?author=myConsciousness\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"#design-myConsciousness\" title=\"Design\"\u003e🎨\u003c/a\u003e \u003ca href=\"#example-myConsciousness\" title=\"Examples\"\u003e💡\u003c/a\u003e \u003ca href=\"#maintenance-myConsciousness\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e \u003ca href=\"https://github.com/mastodon-dart/mastodon-oauth2/commits?author=myConsciousness\" title=\"Tests\"\u003e⚠️\u003c/a\u003e \u003ca href=\"#tutorial-myConsciousness\" title=\"Tutorials\"\u003e✅\u003c/a\u003e\u003c/td\u003e\n       \u003ctd align=\"center\" valign=\"top\" width=\"20%\"\u003e\u003ca href=\"http://markos.dev\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/6950843?v=4?s=100\" width=\"100px;\" alt=\"Mark O'Sullivan\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eMark O'Sullivan\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-MarkOSullivan94\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n       \u003ctd align=\"center\" valign=\"top\" width=\"20%\"\u003e\u003ca href=\"http://abrah.am\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/3341?v=4?s=100\" width=\"100px;\" alt=\"Abraham Williams\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAbraham Williams\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/mastodon-dart/mastodon-oauth2/commits?author=abraham\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/mastodon-dart/mastodon-oauth2/commits?author=abraham\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"https://github.com/mastodon-dart/mastodon-oauth2/commits?author=abraham\" title=\"Tests\"\u003e⚠️\u003c/a\u003e\u003c/td\u003e\n       \u003ctd align=\"center\" valign=\"top\" width=\"20%\"\u003e\u003ca href=\"https://github.com/SkywaveTM\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/4926340?v=4?s=100\" width=\"100px;\" alt=\"YeongJun\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eYeongJun\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/mastodon-dart/mastodon-oauth2/commits?author=SkywaveTM\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"#ideas-SkywaveTM\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n## 1.4. Support ❤️\n\nThe simplest way to show us your support is by **giving the project a star** at [GitHub](https://github.com/mastodon-dart/mastodon-oauth2) and [Pub.dev](https://pub.dev/packages/mastodon_oauth2).\n\nYou can also support this project by **becoming a sponsor** on GitHub:\n\n\u003cdiv align=\"left\"\u003e\n  \u003cp\u003e\n    \u003ca href=\"https://github.com/sponsors/myconsciousness\"\u003e\n      \u003cimg src=\"https://cdn.ko-fi.com/cdn/kofi3.png?v=3\" height=\"50\" width=\"210\" alt=\"myconsciousness\" /\u003e\n    \u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n## 1.5. License 🔑\n\nAll resources of `mastodon_oauth2` is provided under the `BSD-3` license.\n\n```license\nCopyright 2022 Kato Shinya. All rights reserved.\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided the conditions.\n```\n\n\u003e **Note**\u003c/br\u003e\n\u003e License notices in the source are strictly validated based on `.github/header-checker-lint.yml`. Please check [header-checker-lint.yml](https://github.com/mastodon-dart/mastodon-oauth2/tree/main/.github/header-checker-lint.yml) for the permitted standards.\n\n## 1.6. More Information 🧐\n\n`mastodon_oauth2` was designed and implemented by **_Kato Shinya ([@myConsciousness](https://github.com/myConsciousness))_**.\n\n- [Creator Profile](https://github.com/myConsciousness)\n- [License](https://github.com/mastodon-dart/mastodon-oauth2/blob/main/LICENSE)\n- [API Document](https://pub.dev/documentation/mastodon_oauth2/latest/mastodon_oauth2/mastodon_oauth2-library.html)\n- [Release Note](https://github.com/mastodon-dart/mastodon-oauth2/releases)\n- [Bug Report](https://github.com/mastodon-dart/mastodon-oauth2/issues)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FmyConsciousness%2Fmastodon-oauth2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FmyConsciousness%2Fmastodon-oauth2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FmyConsciousness%2Fmastodon-oauth2/lists"}