diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml index a5dbf24..6927068 100644 --- a/.idea/libraries/Dart_Packages.xml +++ b/.idea/libraries/Dart_Packages.xml @@ -5,14 +5,14 @@ - - @@ -89,7 +89,7 @@ - @@ -124,7 +124,7 @@ - @@ -138,7 +138,7 @@ - @@ -166,7 +166,7 @@ - @@ -278,21 +278,21 @@ - - - @@ -341,8 +341,8 @@ - - + + @@ -353,18 +353,18 @@ - + - + - + - + @@ -380,9 +380,9 @@ - - - + + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bdaea4d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) [2023] [Abbas Hussein] + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index b379f51..6ec999a 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ To use the oauth2_manager package with a specific provider, you will need to con To use the Authorization Code Grant flow, first create an instance of the `OAuth2Configuration` class and pass in the parameters: ```dart -import 'package:oauth2_manager/oauth_manager.dart'; +import 'package:oauth2_manager/oauth2_manager.dart'; final oauth2Configuration = OAuth2Configuration( clientID: '', @@ -42,7 +42,7 @@ final credentials = await OAuth2.login( // Open the authorization URL in the user's browser // Example: await launch('$uri'); }, - redirectPage: '', + redirectPage: '', contentType: '', ); ``` diff --git a/example/oauth2_manager_example.dart b/example/oauth2_manager_example.dart index c50402b..3efe48a 100644 --- a/example/oauth2_manager_example.dart +++ b/example/oauth2_manager_example.dart @@ -1,4 +1,4 @@ -import 'package:oauth2_manager/oauth_manager.dart'; +import 'package:oauth2_manager/oauth2_manager.dart'; main() async { /// Google @@ -64,4 +64,32 @@ main() async { tokenEndpoint: 'https://api.amazon.com/auth/o2/token', scopes: [''], ); + + + String authorizationSuccessHtml = ''' + + + + Authorization Success + + +

Authorization Successful

+

You have successfully authorized the application.

+ + + +'''; + + await OAuth2.login( + googleConfiguration, + redirect: (uri) async { + print(uri.toString()); + // Open the authorization URL in the user's browser + // Example: await launch('$uri'); + }, + redirectPage: authorizationSuccessHtml, + contentType: 'text/html', + ); + + } diff --git a/lib/oauth_manager.dart b/lib/oauth2_manager.dart similarity index 100% rename from lib/oauth_manager.dart rename to lib/oauth2_manager.dart diff --git a/lib/src/oauth.dart b/lib/src/oauth.dart index a4f788e..6fc7498 100644 --- a/lib/src/oauth.dart +++ b/lib/src/oauth.dart @@ -1,4 +1,4 @@ -import 'package:oauth2_manager/oauth_manager.dart'; +import 'package:oauth2_manager/oauth2_manager.dart'; import 'package:oauth2_manager/src/typedef.dart'; import 'oauth2_manager.dart'; diff --git a/lib/src/oauth2_manager.dart b/lib/src/oauth2_manager.dart index 9650de5..d731c37 100644 --- a/lib/src/oauth2_manager.dart +++ b/lib/src/oauth2_manager.dart @@ -3,7 +3,7 @@ import 'dart:io'; import 'package:http/http.dart' as http; import 'package:oauth2/oauth2.dart' as oauth2; -import 'package:oauth2_manager/oauth_manager.dart'; +import 'package:oauth2_manager/oauth2_manager.dart'; import 'package:oauth2_manager/src/typedef.dart'; /// An abstract class for managing OAuth2 authentication. @@ -12,7 +12,7 @@ abstract class BaseOAuth2Manager { /// Starts a local server and listens for the redirect URI. /// - /// The `redirectPage` argument is the HTML page to display to the user after the redirect URI is received. + /// The `redirectPage` argument is the HTML page.html to display to the user after the redirect URI is received. /// The `contentType` argument is the content type of the response. /// /// Returns a `Map` of the query parameters in the redirect URI. @@ -35,7 +35,7 @@ abstract class BaseOAuth2Manager { } /// This class extends the BaseOAuth2Manager class and implements the OAuth2 Authorization Code Grant flow. -/// It uses a HttpServer to receive the authorization code and a redirect function to open the authorization page in the user's browser. +/// It uses a HttpServer to receive the authorization code and a redirect function to open the authorization page.html in the user's browser. class OAuth2Manager extends BaseOAuth2Manager { /// The OAuth2 configuration. final OAuth2Configuration _configuration; @@ -45,10 +45,10 @@ class OAuth2Manager extends BaseOAuth2Manager { }) : _configuration = configuration; /// This method initiates the OAuth2 flow by creating a HttpServer to receive the authorization code, - /// opening the authorization page in the user's browser, and handling the authorization response to obtain an OAuth2 token. + /// opening the authorization page.html in the user's browser, and handling the authorization response to obtain an OAuth2 token. /// - /// [redirect] The function used to open the authorization page in the user's browser. - /// [redirectPage] The page to display to the user after the redirect URI is received. + /// [redirect] The function used to open the authorization page.html in the user's browser. + /// [redirectPage] The page.html to display to the user after the redirect URI is received. /// [contentType] The content type of the redirectPage. Future login({ required RedirectUri redirect, diff --git a/pubspec.yaml b/pubspec.yaml index 6ca778f..164dc1d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,11 +4,12 @@ version: 1.0.0 repository: https://github.com/Abbas1Hussein/oauth2_manager environment: - sdk: '>=2.19.0 <3.0.0' + sdk: '>=2.19.0 <4.0.0' dependencies: - oauth2: ^2.0.1 + oauth2: ^2.0.2 + http: ^1.1.0 dev_dependencies: - lints: ^2.0.1 - test: ^1.24.2 + lints: ^2.1.1 + test: ^1.24.5