-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
706390e
commit 536c82e
Showing
2 changed files
with
55 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,67 @@ | ||
import 'package:oauth2_manager/oauth_manager.dart'; | ||
|
||
main() async { | ||
final googleConfiguration = OAuth2Configuration( | ||
clientID: '<client ID>', | ||
clientSecret: '<client secret>', | ||
authorizationEndpoint: 'https://accounts.google.com/o/oauth2/v2/auth', | ||
tokenEndpoint: 'https://oauth2.googleapis.com/token', | ||
scopes: ['<scope>'], | ||
); | ||
|
||
final facebookConfiguration = OAuth2Configuration( | ||
clientID: '<client ID>', | ||
clientSecret: '<client secret>', | ||
authorizationEndpoint: 'https://www.facebook.com/v12.0/dialog/oauth', | ||
tokenEndpoint: 'https://graph.facebook.com/v12.0/oauth/access_token', | ||
scopes: ['<scope>'], | ||
); | ||
|
||
final twitterConfiguration = OAuth2Configuration( | ||
clientID: '<client ID>', | ||
clientSecret: '<client secret>', | ||
authorizationEndpoint: 'https://api.twitter.com/oauth/authenticate', | ||
tokenEndpoint: 'https://api.twitter.com/oauth/access_token', | ||
scopes: ['<scope>'], | ||
); | ||
|
||
final oauth2Configuration = OAuth2Configuration( | ||
/// Github | ||
final githubConfiguration = OAuth2Configuration( | ||
clientID: '<client ID>', | ||
clientSecret: '<client secret>', | ||
tokenEndpoint: '<token endpoint>', | ||
authorizationEndpoint: '<authorization endpoint>', | ||
authorizationEndpoint: 'https://github.com/login/oauth/authorize', | ||
tokenEndpoint: 'https://github.com/login/oauth/access_token', | ||
scopes: ['<scope>'], | ||
); | ||
|
||
final credentials = await OAuth2.login( | ||
oauth2Configuration, | ||
redirect: (uri) async { | ||
// Open the authorization URL in the user's browser | ||
// Example: await launch('$uri'); | ||
}, | ||
redirectPage: '<the page to display after authorization>', | ||
contentType: '<content type of redirectPage>', | ||
final linkedInConfiguration = OAuth2Configuration( | ||
clientID: '<client ID>', | ||
clientSecret: '<client secret>', | ||
authorizationEndpoint: 'https://www.linkedin.com/oauth/v2/authorization', | ||
tokenEndpoint: 'https://www.linkedin.com/oauth/v2/accessToken', | ||
scopes: ['<scope>'], | ||
); | ||
|
||
// credentials.accessToken | ||
// credentials.refreshToken, | ||
// credentials.idToken, | ||
// credentials.expiration | ||
// credentials.isExpired | ||
// credentials.canRefresh | ||
/// Microsoft | ||
final microsoftConfiguration = OAuth2Configuration( | ||
clientID: '<client ID>', | ||
clientSecret: '<client secret>', | ||
authorizationEndpoint: | ||
'https://login.microsoftonline.com/common/oauth2/v2.0/authorize', | ||
tokenEndpoint: 'https://login.microsoftonline.com/common/oauth2/v2.0/token', | ||
scopes: ['<scope>'], | ||
); | ||
|
||
final newCredentials = await OAuth2.getRefreshToken( | ||
credentials.refreshToken!, | ||
newScopes: ['<scope>'], | ||
clientID: oauth2Configuration.clientID, | ||
clientSecret: oauth2Configuration.clientSecret!, | ||
tokenEndpoint: oauth2Configuration.authorizationEndpoint, | ||
/// Amazon | ||
final amazonConfiguration = OAuth2Configuration( | ||
clientID: '<client ID>', | ||
clientSecret: '<client secret>', | ||
authorizationEndpoint: 'https://www.amazon.com/ap/oa', | ||
tokenEndpoint: 'https://api.amazon.com/auth/o2/token', | ||
scopes: ['<scope>'], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export 'package:oauth2_manager/src/oauth2_manager.dart'; | ||
export 'package:oauth2_manager/src/oauth.dart'; | ||
export 'package:oauth2_manager/src/oauth2_configuration.dart'; | ||
export 'package:oauth2/oauth2.dart'; | ||
export 'package:oauth2/oauth2.dart' show Credentials; |