It should work, considering Google themselves ship an OAuth2 client sample
for .NET that uses DNOA underneath. But I'll build a test and see what
happens.
Sent from my Windows Phone
------------------------------
From: Fred
Sent: 7/23/2012 4:26 AM
To: dotnetopenid@googlegroups.com
Subject: [dotnetopenauth] Re: DNOA using OAuth 2 for getting infos from
google
Any ideas?
Is the current implementation of DotNetOpenAuth compatible with google's
implementation or is my problem due to the fact, that OAuth 2 isn't final
yet ?
Wishes,
Manfred
Am Montag, 23. Juli 2012 00:23:00 UTC+2 schrieb Fred:
> I'm trying to access Infos from a google-account using DNOA and OAuth 2. I
> managed to receive an access_code via my callback-url but when I try to get
> a token for it using
> ProcessUserAuthorization Google responds with a 400 Bat Request.
--
You received this message because you are subscribed to the Google Groups
"DotNetOpenAuth" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/dotnetopenid/-/2u4W9KtYFUcJ.
To post to this group, send email to dotnetopenid@googlegroups.com.
To unsubscribe from this group, send email to
dotnetopenid+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/dotnetopenid?hl=en.
what is the URL of this sample? I just found one using a rich client but I try to use a web-client. Meenwhile I found out, that Google replies with a valid token when I construct the request by hand using fiddler, but I'm not able to make DNOA do the same.
I also place my solution, which is - as I seem - pretty Close to the DNOA-sample below - just for in case.
Thx and wishes, Fred
8<-------
public class AuthHelper { public static AuthorizationServerDescription GetAuthServerDescription() { var authServerDescription = new AuthorizationServerDescription(); authServerDescription.AuthorizationEndpoint = new Uri(@" https://accounts.google.com/o/oauth2/auth"); authServerDescription.TokenEndpoint = new Uri(@" https://accounts.google.com/o/oauth2/token"); authServerDescription.ProtocolVersion = ProtocolVersion.V20;
return authServerDescription; } public static WebServerClient CreateClient() {
var desc = GetAuthServerDescription(); return new WebServerClient(desc, clientIdentifier: "some.number.apps.googleusercontent.com", clientSecret: "something_with_underscore_and_a_to_z_and_0_to_9"); }
}
8<------- public class SecureController : Controller { static WebServerClient client = AuthHelper.CreateClient(); public ActionResult OAuth() { if (string.IsNullOrEmpty(Request.QueryString["code"])) { return InitAuth(); } else { return OAuthCallback(); }
> It should work, considering Google themselves ship an OAuth2 client sample > for .NET that uses DNOA underneath. But I'll build a test and see what > happens.
> Sent from my Windows Phone > ------------------------------ > From: Fred > Sent: 7/23/2012 4:26 AM > To: dotnetopenid@googlegroups.com > Subject: [dotnetopenauth] Re: DNOA using OAuth 2 for getting infos from > google
> Any ideas?
> Is the current implementation of DotNetOpenAuth compatible with google's > implementation or is my problem due to the fact, that OAuth 2 isn't final > yet ?
> Wishes, > Manfred
> Am Montag, 23. Juli 2012 00:23:00 UTC+2 schrieb Fred:
>> Hi,
>> I'm trying to access Infos from a google-account using DNOA and OAuth 2. >> I managed to receive an access_code via my callback-url but when I try to >> get a token for it using >> ProcessUserAuthorization Google responds with a 400 Bat Request.
> -- > You received this message because you are subscribed to the Google Groups > "DotNetOpenAuth" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/dotnetopenid/-/2u4W9KtYFUcJ. > To post to this group, send email to dotnetopenid@googlegroups.com. > To unsubscribe from this group, send email to > dotnetopenid+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/dotnetopenid?hl=en.
As for DNOA failing while your own Fiddler-crafted request succeeds, can
you please describe the differences in the request that you observe in
Fiddler? (Or include both failing and succeeding fiddler trace files?)
On Monday, July 23, 2012, Fred wrote:
> Hi Andrew,
> what is the URL of this sample? I just found one using a rich client but I
> try to use a web-client. Meenwhile I found out, that Google replies with a
> valid token when I construct the request by hand using fiddler, but I'm not
> able to make DNOA do the same.
> I also place my solution, which is - as I seem - pretty Close to the
> DNOA-sample below - just for in case.
> Thx and wishes,
> Fred
> 8<-------
> public class AuthHelper
> {
> public static AuthorizationServerDescription GetAuthServerDescription()
> {
> var authServerDescription = new AuthorizationServerDescription();
> authServerDescription.AuthorizationEndpoint = new Uri(@"
> https://accounts.google.com/o/oauth2/auth");
> authServerDescription.TokenEndpoint = new Uri(@"
> https://accounts.google.com/o/oauth2/token");
> authServerDescription.ProtocolVersion = ProtocolVersion.V20;
> }
> private ActionResult InitAuth()
> {
> var uri = Request.Url.AbsoluteUri;
> uri = RemoveQueryStringFromUri(uri);
> var state = new AuthorizationState();
> state.Callback = new Uri(uri);
> state.Scope.Add("https://www.googleapis.com/auth/userinfo.profile > ");
> state.Scope.Add("https://www.googleapis.com/auth/userinfo.email");
> var response = client.PrepareRequestUserAuthorization(state);
> return response.AsActionResult();
> }
> private static string RemoveQueryStringFromUri(string uri)
> {
> int index = uri.IndexOf('?');
> if (index > -1)
> {
> uri = uri.Substring(0, index);
> }
> return uri;
> }
> private ActionResult OAuthCallback()
> {
> // This leads to the Protocol-Exception :-(
> var auth = client.ProcessUserAuthorization(this.Request);
> Session["auth"] = auth;
> return Content("Success!");
> }
> }
> Am Montag, 23. Juli 2012 16:18:16 UTC+2 schrieb Andrew Arnott:
>> It should work, considering Google themselves ship an OAuth2 client
>> sample for .NET that uses DNOA underneath. But I'll build a test and see
>> what happens.
>> Sent from my Windows Phone
>> ------------------------------
>> From: Fred
>> Sent: 7/23/2012 4:26 AM
>> To: dotnetopenid@googlegroups.com <javascript:_e({}, 'cvml',
>> 'dotnetopenid@googlegroups.com');>
>> Subject: [dotnetopenauth] Re: DNOA using OAuth 2 for getting infos from
>> google
>> Any ideas?
>> Is the current implementation of DotNetOpenAuth compatible with google's
>> implementation or is my problem due to the fact, that OAuth 2 isn't final
>> yet ?
>> Wishes,
>> Manfred
>> Am Montag, 23. Juli 2012 00:23:00 UTC+2 schrieb Fred:
>>> Hi,
>>> I'm trying to access Infos from a google-account using DNOA and OAuth 2.
>>> I managed to receive an access_code via my callback-url but when I try to
>>> get a token for it using
>>> ProcessUserAuthorization Google responds with a 400 Bat Request.
>> --
>> You received this message because you are subscribed to the Google Groups
>> "DotNetOpenAuth" group.
>> To view this discussion on the web visit https://groups.google.com/d/** >> msg/dotnetopenid/-/**2u4W9KtYFUcJ<https://groups.google.com/d/msg/dotnetopenid/-/2u4W9KtYFUcJ>
>> .
>> To post to this group, send email to dotnetopenid@googlegroups.com<javascript:_e({}, 'cvml', 'dotnetopenid@googlegroups.com');>
>> .
>> To unsubscribe from this group, send email to dotnetopenid+unsubscribe@**
>> googlegroups.com <javascript:_e({}, 'cvml',
>> 'dotnetopenid%2Bunsubscribe@googlegroups.com');>.
>> For more options, visit this group at http://groups.google.com/** >> group/dotnetopenid?hl=en<http://groups.google.com/group/dotnetopenid?hl=en>
>> .
> --
> You received this message because you are subscribed to the Google Groups
> "DotNetOpenAuth" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/dotnetopenid/-/EQ7AQBnT-cYJ.
> To post to this group, send email to dotnetopenid@googlegroups.com<javascript:_e({}, 'cvml', 'dotnetopenid@googlegroups.com');>
> .
> To unsubscribe from this group, send email to
> dotnetopenid+unsubscribe@googlegroups.com <javascript:_e({}, 'cvml',
> 'dotnetopenid%2Bunsubscribe@googlegroups.com');>.
> For more options, visit this group at
> http://groups.google.com/group/dotnetopenid?hl=en.
-- --
Andrew Arnott
"I [may] not agree with what you have to say, but I'll defend to the death
your right to say it." - S. G. Tallentyre
I think, Google expects credentials within the message. If there are no credentials, it replies with a 400 instead of sending a 401. On the other hand, I think DNOA only sends credentials after it got a 401.
[1] is the request, DNOA created in my case; [2] is the response to it. When I include the credentials (see [3]) in the message according to [4], everything works fine.
> As for DNOA failing while your own Fiddler-crafted request succeeds, can > you please describe the differences in the request that you observe in > Fiddler? (Or include both failing and succeeding fiddler trace files?)
> On Monday, July 23, 2012, Fred wrote:
>> Hi Andrew,
>> what is the URL of this sample? I just found one using a rich client but >> I try to use a web-client. Meenwhile I found out, that Google replies with >> a valid token when I construct the request by hand using fiddler, but I'm >> not able to make DNOA do the same.
>> I also place my solution, which is - as I seem - pretty Close to the >> DNOA-sample below - just for in case.
>> Thx and wishes, >> Fred
>> 8<-------
>> public class AuthHelper >> { >> public static AuthorizationServerDescription >> GetAuthServerDescription() >> { >> var authServerDescription = new AuthorizationServerDescription(); >> authServerDescription.AuthorizationEndpoint = new Uri(@" >> https://accounts.google.com/o/oauth2/auth"); >> authServerDescription.TokenEndpoint = new Uri(@" >> https://accounts.google.com/o/oauth2/token"); >> authServerDescription.ProtocolVersion = ProtocolVersion.V20;
>> } >> private ActionResult InitAuth() >> { >> var uri = Request.Url.AbsoluteUri; >> uri = RemoveQueryStringFromUri(uri); >> var state = new AuthorizationState(); >> state.Callback = new Uri(uri); >> state.Scope.Add("https://www.googleapis.com/auth/userinfo.profile >> "); >> state.Scope.Add("https://www.googleapis.com/auth/userinfo.email >> "); >> var response = client.PrepareRequestUserAuthorization(state);
>> return response.AsActionResult(); >> } >> private static string RemoveQueryStringFromUri(string uri) >> { >> int index = uri.IndexOf('?'); >> if (index > -1) >> { >> uri = uri.Substring(0, index); >> } >> return uri; >> } >> private ActionResult OAuthCallback() >> { >> // This leads to the Protocol-Exception :-( >> var auth = client.ProcessUserAuthorization(this.Request); >> Session["auth"] = auth; >> return Content("Success!");
>> } >> }
>> Am Montag, 23. Juli 2012 16:18:16 UTC+2 schrieb Andrew Arnott:
>>> It should work, considering Google themselves ship an OAuth2 client >>> sample for .NET that uses DNOA underneath. But I'll build a test and see >>> what happens.
>>> Sent from my Windows Phone >>> ------------------------------ >>> From: Fred >>> Sent: 7/23/2012 4:26 AM >>> To: dotnetopenid@googlegroups.com >>> Subject: [dotnetopenauth] Re: DNOA using OAuth 2 for getting infos from >>> google
>>> Any ideas?
>>> Is the current implementation of DotNetOpenAuth compatible with google's >>> implementation or is my problem due to the fact, that OAuth 2 isn't final >>> yet ?
>>> Wishes, >>> Manfred
>>> Am Montag, 23. Juli 2012 00:23:00 UTC+2 schrieb Fred:
>>>> Hi,
>>>> I'm trying to access Infos from a google-account using DNOA and OAuth >>>> 2. I managed to receive an access_code via my callback-url but when I try >>>> to get a token for it using >>>> ProcessUserAuthorization Google responds with a 400 Bat Request.
>> -- >> You received this message because you are subscribed to the Google Groups >> "DotNetOpenAuth" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/dotnetopenid/-/EQ7AQBnT-cYJ. >> To post to this group, send email to dotnetopenid@googlegroups.com. >> To unsubscribe from this group, send email to >> dotnetopenid+unsubscribe@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/dotnetopenid?hl=en.
> -- > -- > Andrew Arnott > "I [may] not agree with what you have to say, but I'll defend to the death > your right to say it." - S. G. Tallentyre
Thanks, Fred. I think Google is following the OAuth 2 spec here (although
the error should probably be "invalid_client" instead of
"invalid_request"), and DNOA isn't responding to the HTTP 400 error as you
say. Thanks very much for doing this investigation and reporting your
findings. Getting DNOA to respond to HTTP 400 appropriately is something
we can certainly do. HttpWebRequest strips out the Authorization header
when I try to put it into the initial request -- it's as if .NET refuses to
send it except in response to an HTTP 401 response. So we may have to
throw HttpWebRequest out and use something else -- that might actually
require that we take a dependency on .NET 4.0. Hmmm... This requires more
thought.
On Tuesday, July 24, 2012, Fred wrote:
> Hi Andrew,
> I think, Google expects credentials within the message. If there are no
> credentials, it replies with a 400 instead of sending a 401. On the other
> hand, I think DNOA only sends credentials after it got a 401.
> [1] is the request, DNOA created in my case; [2] is the response to it.
> When I include the credentials (see [3]) in the message according to [4],
> everything works fine.
> As for DNOA failing while your own Fiddler-crafted request succeeds, can
> you please describe the differences in the request that you observe in
> Fiddler? (Or include both failing and succeeding fiddler trace files?)
> On Monday, July 23, 2012, Fred wrote:
> Hi Andrew,
> what is the URL of this sample? I just found one using a rich client but I
> try to use a web-client. Meenwhile I found out, that Google replies with a
> valid token when I construct the request by hand using fiddler, but I'm not
> able to make DNOA do the same.
> I also place my solution, which is - as I seem - pretty Close to the
> DNOA-sample below - just for in case.
> return response.AsActionResult();
> }
> private static string RemoveQueryStringFromUri(**string uri)
> {
> int index = uri.IndexOf('?');
> if (index > -1)
> {
> uri = uri.Substring(0, index);
> }
> return uri;
> }
> private ActionResult OAuthCallback()
> {
> // This leads to the Protocol-Exception :-(
> var auth = client.**ProcessUserAuthorization(this.**Request);
> Session["auth"] = auth;
> return Content("Success!");
> }
> }
> Am Montag, 23. Juli 2012 16:18:16 UTC+2 schrieb Andrew Arnott:
> It should work, considering Google themselves ship an OAuth2 client sample
> for .NET that uses DNOA underneath. But
> To view this discussion on the web visit
> https://groups.google.com/d/msg/dotnetopenid/-/1T6eJwIw3EQJ.
> To post to this group, send email to dotnetopenid@googlegroups.com<javascript:_e({}, 'cvml', 'dotnetopenid@googlegroups.com');>
> .
> To unsubscribe from this group, send email to
> dotnetopenid+unsubscribe@googlegroups.com <javascript:_e({}, 'cvml',
> 'dotnetopenid%2Bunsubscribe@googlegroups.com');>.
> For more options, visit this group at
> http://groups.google.com/group/dotnetopenid?hl=en.
-- --
Andrew Arnott
"I [may] not agree with what you have to say, but I'll defend to the death
your right to say it." - S. G. Tallentyre
I've filed a bug at [1] and attached some suggestions for solving this issue (without to require .NET 4).
Is it possible to attach custom FORM-Parameter? If yes, I could quickly solve this issue in my demo-code by passing the credentials within the payload.
> Thanks, Fred. I think Google is following the OAuth 2 spec here (although > the error should probably be "invalid_client" instead of > "invalid_request"), and DNOA isn't responding to the HTTP 400 error as you > say. Thanks very much for doing this investigation and reporting your > findings. Getting DNOA to respond to HTTP 400 appropriately is something > we can certainly do. HttpWebRequest strips out the Authorization header > when I try to put it into the initial request -- it's as if .NET refuses to > send it except in response to an HTTP 401 response. So we may have to > throw HttpWebRequest out and use something else -- that might actually > require that we take a dependency on .NET 4.0. Hmmm... This requires more > thought.
>> I think, Google expects credentials within the message. If there are no >> credentials, it replies with a 400 instead of sending a 401. On the other >> hand, I think DNOA only sends credentials after it got a 401.
>> [1] is the request, DNOA created in my case; [2] is the response to it. >> When I include the credentials (see [3]) in the message according to [4], >> everything works fine.
>> As for DNOA failing while your own Fiddler-crafted request succeeds, can >> you please describe the differences in the request that you observe in >> Fiddler? (Or include both failing and succeeding fiddler trace files?)
>> On Monday, July 23, 2012, Fred wrote:
>> Hi Andrew,
>> what is the URL of this sample? I just found one using a rich client but >> I try to use a web-client. Meenwhile I found out, that Google replies with >> a valid token when I construct the request by hand using fiddler, but I'm >> not able to make DNOA do the same.
>> I also place my solution, which is - as I seem - pretty Close to the >> DNOA-sample below - just for in case.
Thanks, Fred. I forgot that yes, you can force the client creds to be
included as a form parameter. Just set the client's
ClientCredentialApplicator property
to ClientCredentialApplicator.PostParameter(secret) and you'll get the
behavior you're asking for.
--
Andrew Arnott
"I [may] not agree with what you have to say, but I'll defend to the death
your right to say it." - S. G. Tallentyre
On Tue, Jul 24, 2012 at 8:32 PM, Fred <manfred.ste...@gmx.net> wrote:
> Hi Andrew,
> I've filed a bug at [1] and attached some suggestions for solving this
> issue (without to require .NET 4).
> Is it possible to attach custom FORM-Parameter? If yes, I could quickly
> solve this issue in my demo-code by passing the credentials within the
> payload.
> Am Mittwoch, 25. Juli 2012 02:06:55 UTC+2 schrieb Andrew Arnott:
>> Thanks, Fred. I think Google is following the OAuth 2 spec here
>> (although the error should probably be "invalid_client" instead of
>> "invalid_request"), and DNOA isn't responding to the HTTP 400 error as you
>> say. Thanks very much for doing this investigation and reporting your
>> findings. Getting DNOA to respond to HTTP 400 appropriately is something
>> we can certainly do. HttpWebRequest strips out the Authorization header
>> when I try to put it into the initial request -- it's as if .NET refuses to
>> send it except in response to an HTTP 401 response. So we may have to
>> throw HttpWebRequest out and use something else -- that might actually
>> require that we take a dependency on .NET 4.0. Hmmm... This requires more
>> thought.
>>> I think, Google expects credentials within the message. If there are no
>>> credentials, it replies with a 400 instead of sending a 401. On the other
>>> hand, I think DNOA only sends credentials after it got a 401.
>>> [1] is the request, DNOA created in my case; [2] is the response to it.
>>> When I include the credentials (see [3]) in the message according to [4],
>>> everything works fine.
>>> As for DNOA failing while your own Fiddler-crafted request succeeds, can
>>> you please describe the differences in the request that you observe in
>>> Fiddler? (Or include both failing and succeeding fiddler trace files?)
>>> On Monday, July 23, 2012, Fred wrote:
>>> Hi Andrew,
>>> what is the URL of this sample? I just found one using a rich client but
>>> I try to use a web-client. Meenwhile I found out, that Google replies with
>>> a valid token when I construct the request by hand using fiddler, but I'm
>>> not able to make DNOA do the same.
>>> I also place my solution, which is - as I seem - pretty Close to the
>>> DNOA-sample below - just for in case.
>> --
>> --
>> Andrew Arnott
>> "I [may] not agree with what you have to say, but I'll defend to the
>> death your right to say it." - S. G. Tallentyre
> To post to this group, send email to dotnetopenid@googlegroups.com.
> To unsubscribe from this group, send email to
> dotnetopenid+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/dotnetopenid?hl=en.
On Tuesday, July 24, 2012 11:34:12 PM UTC-5, Andrew Arnott wrote:
> Thanks, Fred. I forgot that yes, you can force the client creds to be > included as a form parameter. Just set the client's > ClientCredentialApplicator property > to ClientCredentialApplicator.PostParameter(secret) and you'll get the > behavior you're asking for. > -- > Andrew Arnott > "I [may] not agree with what you have to say, but I'll defend to the death > your right to say it." - S. G. Tallentyre