From 2700874c6d6863e54d35c49f6f46fbffe80497b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jirka=20Dan=C4=9Bk?= Date: Fri, 12 Dec 2014 14:08:19 +0100 Subject: [PATCH] Add hostedDomain parameter suggested at http://stackoverflow.com/a/11001585/1047788 --- lib/src/browser/google_oauth2.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/browser/google_oauth2.dart b/lib/src/browser/google_oauth2.dart index b947027..7c4e6fe 100644 --- a/lib/src/browser/google_oauth2.dart +++ b/lib/src/browser/google_oauth2.dart @@ -8,6 +8,7 @@ class GoogleOAuth2 extends OAuth2 { final List _request_visible_actions; final String _provider; final String _tokenValidationUri; + final String _hostedDomain; final Function _tokenLoaded; final Function _tokenNotLoaded; String _approval_prompt; @@ -28,6 +29,8 @@ class GoogleOAuth2 extends OAuth2 { * * * [provider] the URI to provide Google OAuth2 authentication. * * [tokenValidationUri] the URI to validate OAuth2 tokens against. + * * [hostedDomain] restricts login to a Google Apps domain, see + * https://developers.google.com/accounts/docs/OpenIDConnect#hd-param * * [clientId] Client id for the Google API app. For example, for Google * Books, use "796343192238.apps.googleusercontent.com". * * [scopes] list of scopes (kinds of information) you are planning to use. @@ -45,6 +48,7 @@ class GoogleOAuth2 extends OAuth2 { { List request_visible_actions: null, String provider: "https://accounts.google.com/o/oauth2/", String tokenValidationUri: "https://www.googleapis.com/oauth2/v1/tokeninfo", + String hostedDomain: "", tokenLoaded(Token token), tokenNotLoaded(), bool autoLogin: false, @@ -52,6 +56,7 @@ class GoogleOAuth2 extends OAuth2 { String approval_prompt: null}) : _provider = provider, _tokenValidationUri = tokenValidationUri, + _hostedDomain = hostedDomain, _tokenLoaded = tokenLoaded, _tokenNotLoaded = tokenNotLoaded, _request_visible_actions = request_visible_actions, @@ -116,7 +121,8 @@ class GoogleOAuth2 extends OAuth2 { "redirect_uri": "postmessage", // Response will post to the proxy iframe "scope": _scopes.join(" "), "immediate": immediate, - "approval_prompt": _approval_prompt + "approval_prompt": _approval_prompt, + "hd": _hostedDomain }; if (_request_visible_actions != null && _request_visible_actions.length > 0) { queryParams["request_visible_actions"] = _request_visible_actions.join(" ");