Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
31e8d5a
Fix some typos in README
ThexXTURBOXx Aug 2, 2024
f215910
Update flutter_web_auth_2 to 4.x alpha
ThexXTURBOXx Aug 2, 2024
f6f1c06
Allow more customization in flutter_web_auth_2
ThexXTURBOXx Aug 2, 2024
f7f0d95
Update flutter_web_auth_2 constraint even more
ThexXTURBOXx Oct 29, 2024
372c96f
Allow sending signed streamed requests
ThexXTURBOXx Oct 29, 2024
de8e1f3
Allow even more request types
ThexXTURBOXx Oct 29, 2024
7aa9f38
Try to migrate to WASM
ThexXTURBOXx Oct 29, 2024
ad21b35
Update linter
ThexXTURBOXx Oct 29, 2024
ba69607
Update to flutter_secure_storage 10 beta
ThexXTURBOXx Feb 18, 2025
3cb2f1c
Fix lint
ThexXTURBOXx Feb 18, 2025
ed4d0c3
Update CI
ThexXTURBOXx Feb 18, 2025
17e824b
Also run linter in CI
ThexXTURBOXx Feb 18, 2025
5472981
Add comment about send(...) approach
ThexXTURBOXx Feb 18, 2025
b5d828c
Test send(...) approach
ThexXTURBOXx Feb 18, 2025
0be7530
Migrate away from deprecated functions
ThexXTURBOXx Mar 5, 2025
0400ae7
Update flutter_web_auth_2 to 5.x alpha
ThexXTURBOXx Mar 5, 2025
1f4b07c
Change repo owner
ThexXTURBOXx Mar 9, 2025
a5f0da6
Bump version and add changelog
ThexXTURBOXx Mar 9, 2025
619f62b
Update Dart SDK requirement to >=3.5.0
ThexXTURBOXx Mar 9, 2025
84963a6
Remove unnecessary workflow
ThexXTURBOXx Mar 9, 2025
edc941a
Updated README
ThexXTURBOXx Mar 9, 2025
9ce6141
Fix example
ThexXTURBOXx Mar 9, 2025
68af478
Allow changing the client_id and client_secret key names
ThexXTURBOXx Mar 9, 2025
9ac6aae
Add funding
ThexXTURBOXx Mar 9, 2025
f5aee75
Add issue templates
ThexXTURBOXx Mar 9, 2025
683576f
Modernise pubspecs
ThexXTURBOXx Mar 9, 2025
1acfebe
Remove cruft
ThexXTURBOXx Mar 9, 2025
6a6b91d
Bump version and add changelog
ThexXTURBOXx Mar 9, 2025
39dcfd5
Add preliminary TikTok client
ThexXTURBOXx Mar 10, 2025
215209c
Add another header
ThexXTURBOXx Mar 11, 2025
772afaa
Add proper example code
ThexXTURBOXx Mar 12, 2025
7df687b
Fix content type issues
ThexXTURBOXx Mar 12, 2025
774dd06
Update documentation
ThexXTURBOXx Mar 12, 2025
c37a327
Bump version and add changelog
ThexXTURBOXx Mar 12, 2025
04e9b60
Fix tests
ThexXTURBOXx Mar 12, 2025
636c29c
Add custom parameter support to revoke functions
ThexXTURBOXx Apr 30, 2025
129851b
Bump version and add changelog
ThexXTURBOXx Apr 30, 2025
8cf82bc
Oops, didn't properly update changelog
ThexXTURBOXx Apr 30, 2025
2aac7d0
Update lints
ThexXTURBOXx Jun 26, 2025
9c4eef4
Update dependencies
ThexXTURBOXx Nov 27, 2025
d9a2a1c
Remove unnecessary dependency on meta
ThexXTURBOXx Nov 27, 2025
c8f00e2
Update CI
ThexXTURBOXx Nov 27, 2025
6d2771b
Bump version and add changelog
ThexXTURBOXx Nov 27, 2025
4b4af83
Bump flutter_secure_storage to stable 10.x
ThexXTURBOXx Dec 14, 2025
430b783
Bump checkout action
ThexXTURBOXx Dec 14, 2025
f613a92
Bump version and add changelog
ThexXTURBOXx Dec 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These are supported funding model platforms

github: ThexXTURBOXx
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
96 changes: 96 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Bug report
description: Create a bug report to help us improve
title: '[Bug]: <Choose an appropriate title>'
labels:
- bug
assignees:
- ThexXTURBOXx
body:
- type: textarea
attributes:
label: Description
description: A clear and concise description of the problem
placeholder: Currently, I am trying to [...]
validations:
required: true
- type: textarea
attributes:
label: Minimal Reproduction
description: Provide steps to reproduce the problem
placeholder: 'Steps to reproduce the behaviour: [...]'
value: |-
Steps to reproduce the behaviour:

1. Use the following code:
```dart
<Paste your code here>
```
2. [...]
validations:
required: true
- type: textarea
attributes:
label: Exception or Error
description: Provide error logs
placeholder: Copy paste from the log/console
validations:
required: true
- type: textarea
attributes:
label: Expected Behaviour
description: A clear and concise description of what you expected to happen
placeholder: The package should [...]
validations:
required: true
- type: textarea
attributes:
label: Screenshots
description: If applicable, add screenshots to help explain your problem
placeholder: You can upload screenshots by drag’n’drop
- type: textarea
attributes:
label: Additional context
description: Add any other context about the problem here
- type: markdown
attributes:
value: '# Environment'
- type: input
attributes:
label: Device
placeholder: e.g. iPhone 6, Desktop Computer
validations:
required: true
- type: input
attributes:
label: OS
placeholder: e.g. iOS 8.1, Windows 10 21H2
validations:
required: true
- type: input
attributes:
label: Browser
placeholder: e.g. Stock, Chrome, Safari, Firefox
validations:
required: true
- type: input
attributes:
label: Flutter version
placeholder: e.g. 3.21.1
validations:
required: true
- type: input
attributes:
label: oauth2_client version
placeholder: e.g. 4.0.0
validations:
required: true
- type: checkboxes
attributes:
label: Checklist
options:
- label: >-
I have read and followed the **entire** [README](https://github.com/ThexXTURBOXx/oauth2_client/blob/master/README.md)
and it has not provided the solution I need.
required: true
- label: I have provided all the information I can.
required: true
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ThexXTURBOXx

---

## Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

## Describe the solution you'd like
A clear and concise description of what you want to happen.

## Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

## Additional context
Add any other context or screenshots about the feature request here.
49 changes: 23 additions & 26 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,40 @@


# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build-and-test:
# The type of runner that the job will run on
name: Build and Test
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v6

- name: Install Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'

- uses: actions/setup-java@v1
with:
java-version: '12.x'
- name: Setup Pana
run: flutter pub global activate pana

- uses: subosito/[email protected]
#with:
# The Flutter version to make available on the path
# flutter-version:
- name: Get dependencies
run: flutter pub get

# Get flutter packages
- run: flutter pub get
- name: Lint
run: dart format -o none --set-exit-if-changed .

- run: flutter analyze
- name: Analyze
run: dart analyze

- run: flutter test --coverage
- run: flutter test --coverage

- uses: codecov/[email protected]
- uses: codecov/codecov-action@v5
with:
token: ${{secrets.CODECOV_TOKEN}}
files: ./coverage/lcov.info

with:
token: ${{secrets.CODECOV_TOKEN}}
file: ./coverage/lcov.info
- name: Pana
run: pana
14 changes: 0 additions & 14 deletions .github/workflows/create_release.yml

This file was deleted.

28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
## [4.2.2] - 2025/12/14
* Bump `flutter_secure_storage` to stable `10.x`

## [4.2.1] - 2025/11/27
* Update dependency constraints
* Update and fix lints
* Remove unnecessary dependency on `meta` package

## [4.2.0] - 2025/04/30
* Add support for optional parameters in revoke function

## [4.1.0] - 2025/03/12
* Add TikTok OAuth 2.0 client
* Fix example
* Fix issues with HTTP `Content-Type` headers using a dirty workaround

## [4.0.1] - 2025/03/09
* Update documentation properly
* Fix a few typos here and there
* Allow changing the client ID and client secret key names

## [4.0.0] - 2025/03/09
* This package changed maintainer (to [ThexXTURBOXx](https://github.com/ThexXTURBOXx))
* Updated Dart SDK requirement to `>=3.5.0` (it is the most common nowadays and basically required)
* Updated all dependencies (with breaking changes!)
* Migrate to `web` and add WASM support
* Allow `send` HTTP requests

## [3.3.0] - 2024/07/03
* Updated dependencies
* Fix: Check for null value before casting scope to String (thanks [xolf](https://github.com/xolf))
Expand Down
60 changes: 38 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![codecov](https://codecov.io/gh/teranetsrl/oauth2_client/branch/master/graph/badge.svg)](https://codecov.io/gh/teranetsrl/oauth2_client)
[![codecov](https://codecov.io/gh/ThexXTURBOXx/oauth2_client/branch/master/graph/badge.svg)](https://codecov.io/gh/ThexXTURBOXx/oauth2_client)

# oauth2_client
Simple Flutter library for interacting with OAuth2 servers. It provides convenience classes for interacting with the "usual suspects" (Google, Facebook, LinkedIn, GitHub), but it's particularly suited for implementing clients for custom OAuth2 servers.
Expand All @@ -12,7 +12,7 @@ On Android you must first set the *minSdkVersion* in the *build.gradle* file:
```
defaultConfig {
...
minSdkVersion 18
minSdkVersion 23
...
```

Expand All @@ -31,7 +31,7 @@ AndroidManifest.xml
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="my.test.app" /> <!-- This must correspond to the custom scheme used for instantiatng the client... See below -->
<data android:scheme="my.test.app" /> <!-- This must correspond to the custom scheme used for instantiating the client... See below -->
</intent-filter>
</activity>
```
Expand Down Expand Up @@ -71,10 +71,20 @@ Add the library to your *pubspec.yaml* file:

```yaml
dependencies:
oauth2_client: ^3.0.0
oauth2_client: ^4.0.0
```

## Upgrading from previous versions (< 3.0.0)
After that, please also follow the setup guides of [flutter_web_auth_2](https://pub.dev/packages/flutter_web_auth_2) as well as
[flutter_secure_storage](https://pub.dev/packages/flutter_secure_storage).

## Upgrading to 4.0.0
Compared to 3.0.0, there are not that many breaking changes. Just be aware that:
* This package changed maintainer (to [ThexXTURBOXx](https://github.com/ThexXTURBOXx))
* We updated the Dart SDK requirement to `>=3.5.0` (it is the most common nowadays and basically required)
* We updated all dependencies (some with breaking changes - in particular, you might need to also follow these migration guides: https://github.com/ThexXTURBOXx/flutter_web_auth_2?tab=readme-ov-file#migration)
* We migrated to `web` and added WASM support

## Upgrading to 3.0.0
Version 3.0.0 introduced some breaking changes that need to be addressed if you are upgrading from previous versions.

Please take note of the following:
Expand Down Expand Up @@ -155,7 +165,7 @@ import 'package:http/http.dart' as http;
//Instantiate an OAuth2Client...
GoogleOAuth2Client client = GoogleOAuth2Client(
customUriScheme: 'my.test.app', //Must correspond to the AndroidManifest's "android:scheme" attribute
redirectUri: 'my.test.app:/oauth2redirect', //Can be any URI, but the scheme part must correspond to the customeUriScheme
redirectUri: 'my.test.app:/oauth2redirect', //Can be any URI, but the scheme part must correspond to the customUriScheme
);

//Then, instantiate the helper passing the previously instantiated client
Expand Down Expand Up @@ -217,8 +227,8 @@ if(tknResp.isExpired()) {
}
```

## Acessing custom/non standard response fields ##
You can access non standard fields in the response by calling the ```getRespField``` method.
## Accessing custom/non standard response fields ##
You can access non standard fields in the response by calling the `getRespField` method.

For example:
```dart
Expand All @@ -235,14 +245,16 @@ if(tknResp.isExpired()) {
# Predefined clients #
The library implements clients for the following services/organizations:

- Google
- Facebook
- LinkedIn
- GitHub
- Shopify
- Spotify
- Twitter
- Microsoft
- Facebook
- GitHub
- Google
- LinkedIn
- Microsoft
- Reddit
- Shopify
- Spotify
- TikTok
- Twitter

## Google client ##

Expand All @@ -251,7 +263,7 @@ In order to use this client you need to first configure OAuth2 credentials in th
First you need to create a new Project if it doesn't already exists, then you need to create the OAuth2 credentials ("OAuth Client ID").

Select **iOS** as *Application Type*, specify a name for the client and a *Bundle ID*.
Now edit the just created Client ID and take note of the "IOS URL scheme". This should look something like ``com.googleusercontent.apps.XXX`` and is the custom scheme you'll need to use.
Now edit the just created Client ID and take note of the "IOS URL scheme". This should look something like `com.googleusercontent.apps.XXX` and is the custom scheme you'll need to use.

Then in your code:

Expand Down Expand Up @@ -302,7 +314,7 @@ Then you can instantiate an helper class or directly use the client methods to a

## GitHub client ##

In order to use this client you need to first create a new OAuth2 App in the GittHub Developer Settings (https://github.com/settings/developers)
In order to use this client you need to first create a new OAuth2 App in the GitHub Developer Settings (https://github.com/settings/developers)

Then in your code:

Expand All @@ -317,10 +329,14 @@ OAuth2Client ghClient = GitHubOAuth2Client(

Then you can instantiate an helper class or directly use the client methods to acquire access tokens.

## Other clients

The other pre-defined clients should follow roughly the same scheme as the ones mentioned above.

# Implementing your own client #
Implementing your own client is quite simple, and often it requires only few lines of code.

In the majority of cases you only need to extend the base *OAuth2Client* class and configure the proper endpoints for the authorization and token url.
In the majority of cases you only need to extend the base `OAuth2Client` class and configure the proper endpoints for the authorization and token url.

```dart
import 'package:oauth2_client/oauth2_client.dart';
Expand Down Expand Up @@ -372,9 +388,9 @@ print(tknResp.scope);
Apart from the order, the printed scopes should correspond **exactly** to the ones you requested.

### I get an error *PlatformException(CANCELED, User canceled login, null, null)* on Android ###
Please make sure you modified the *AndroidManifest.xml* file adding the ```com.linusu.flutter_web_auth_2.CallbackActivity``` and the intent filter needed to open the browser window for the authorization workflow.
Please make sure you modified the *AndroidManifest.xml* file adding the `om.linusu.flutter_web_auth_2.CallbackActivity` and the intent filter needed to open the browser window for the authorization workflow.

The AndroidManifest.xml file must contain the ```com.linusu.flutter_web_auth_2.CallbackActivity``` activity. Copy and paste the below code and CHANGE the value of `android:scheme` to match the scheme used in the redirect uri:
The AndroidManifest.xml file must contain the `com.linusu.flutter_web_auth_2.CallbackActivity` activity. Copy and paste the below code and CHANGE the value of `android:scheme` to match the scheme used in the redirect uri:

```xml
<activity android:name="com.linusu.flutter_web_auth_2.CallbackActivity" android:exported="true">
Expand All @@ -392,7 +408,7 @@ If you are sure your intent filter is set up correctly, maybe you have another o
### Can I use https instead of a custom scheme? ###

If you want to use an HTTPS url as the redirect uri, you must set it up as an [App Link](https://developer.android.com/training/app-links/index.html).
First you need to specify both the ```android:host``` and ```android:pathPrefix``` attributes, as long as the ```android:autoVerify="true"``` attribute in the intent-filter tag inside the _AndroidManifest.xml_:
First you need to specify both the `android:host` and `android:pathPrefix` attributes, as long as the `android:autoVerify="true"` attribute in the intent-filter tag inside the _AndroidManifest.xml_:

```xml
<activity android:name="com.linusu.flutter_web_auth_2.CallbackActivity">
Expand Down
Loading