oauth2restclient 0.0.1
oauth2restclient: ^0.0.1 copied to clipboard
OAuth2 login and rest client
OAuth2RestClient A Dart/Flutter package that simplifies OAuth2 authentication and REST API interactions with automatic token management.
Features #
OAuth2 Authentication: Easy implementation of OAuth2 login flows
Account Management: Securely store and load user accounts and tokens
Automatic Token Handling: Transparently manages access tokens in request headers
Token Refresh: Automatically refreshes expired tokens when needed
Service Integration: Simplifies integration with REST APIs like Google Drive
Usage #
final account = OAuth2Account();
var google = Google
(
redirectUri: "com.googleusercontent.apps.95012368401-j0gcpfork6j38q3p8sg37admdo086gbs:/oauth2redirect",
scopes: ['https://www.googleapis.com/auth/drive', "https://www.googleapis.com/auth/photoslibrary", "openid", "email"],
clientId: dotenv.env["MOBILE_CLIENT_ID"]!
);
if (Platform.isMacOS)
{
google = Google
(
redirectUri: "http://localhost:8713/pobpob",
scopes: ['https://www.googleapis.com/auth/drive', "https://www.googleapis.com/auth/photoslibrary", "openid", "email"],
clientId: dotenv.env["DESKTOP_CLIENT_ID"]!,
clientSecret:dotenv.env["DESKTOP_CLIENT_SECRET"]!,
);
}
account.addProvider("google", google);
var token = await account.newLogin("google");
//or
token = await account.loadAccount("google", "userName")
var client = await account.createClient(token);