Skip to content
Browse files

Allow other scope uris

Some scopes are not based from the default url.  If the scope starts
with http, it will use it as-is.  Otherwise, the baseuri of
https://www.googleapis.com/auth/ will be used.
  • Loading branch information...
1 parent 0b23682 commit 121e97bef0eebe8cfa90d88684ff5c58e0031d64 @mj1856 committed
Showing with 3 additions and 4 deletions.
  1. +3 −4 DotNetOpenAuth.GoogleOAuth2/GoogleOAuth2Client.cs
View
7 DotNetOpenAuth.GoogleOAuth2/GoogleOAuth2Client.cs
@@ -85,9 +85,6 @@ public GoogleOAuth2Client(string clientId, string clientSecret, params string[]
if (requestedScopes.Length == 0)
throw new ArgumentException("One or more scopes must be requested.", "requestedScopes");
- if (requestedScopes.Any(x => x.StartsWith("http:", StringComparison.OrdinalIgnoreCase)))
- throw new ArgumentException("Specify scopes without the base uri (" + ScopeBaseUri + ")");
-
_clientId = clientId;
_clientSecret = clientSecret;
_requestedScopes = requestedScopes;
@@ -95,11 +92,13 @@ public GoogleOAuth2Client(string clientId, string clientSecret, params string[]
protected override Uri GetServiceLoginUrl(Uri returnUrl)
{
+ var scopes = _requestedScopes.Select(x => !x.StartsWith("http", StringComparison.OrdinalIgnoreCase) ? ScopeBaseUri + x : x);
+
return BuildUri(AuthorizationEndpoint, new NameValueCollection
{
{ "response_type", "code" },
{ "client_id", _clientId },
- { "scope", string.Join(" ", _requestedScopes.Select(x => ScopeBaseUri + x)) },
+ { "scope", string.Join(" ", scopes) },
{ "redirect_uri", returnUrl.GetLeftPart(UriPartial.Path) },
{ "state", returnUrl.Query.Substring(1) },
});

0 comments on commit 121e97b

Please sign in to comment.
Something went wrong with that request. Please try again.