Skip to content

Commit 3c3da04

Browse files
committed
Merge pull request #48 from enyo/master
Added a 'authorziationResponseServerPort' configuration option.
2 parents bd356b9 + 7e22dbe commit 3c3da04

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/src/console/oauth2_console_client/oauth2.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,18 @@ class OAuth2Console {
5858

5959
final String credentialsFilePath;
6060

61+
/// The port that should be used for the one-shot authorization response
62+
/// server
63+
final int authorizationResponseServerPort;
64+
6165
PubHttpClient _httpClient;
6266

6367
OAuth2Console({String identifier: null, String secret: null,
6468
Uri authorizationEndpoint: null, Uri tokenEndpoint: null, List scopes: null,
6569
List<String> request_visible_actions: null,
6670
this.authorizedRedirect: 'https://github.com/dart-gde/dart-google-oauth2-library',
67-
this.credentialsFilePath: 'credentials.json'}) {
71+
this.credentialsFilePath: 'credentials.json',
72+
this.authorizationResponseServerPort: 0}) {
6873

6974
if (identifier != null) this._identifier = identifier;
7075
if (secret != null) this._secret = secret;
@@ -182,7 +187,7 @@ class OAuth2Console {
182187
// Spin up a one-shot HTTP server to receive the authorization code from the
183188
// Google OAuth2 server via redirect. This server will close itself as soon as
184189
// the code is received.
185-
return SafeHttpServer.bind('127.0.0.1', 0).then((server) {
190+
return SafeHttpServer.bind('127.0.0.1', authorizationResponseServerPort).then((server) {
186191
var authUrl = grant.getAuthorizationUrl(
187192
Uri.parse('http://localhost:${server.port}'), scopes: _scopes);
188193

0 commit comments

Comments
 (0)