Gonzalo,
Could I trouble you to confirm the version of the client library that you
are using?
The issue seems to be on the line in bold:
string body = string.Format(
"code={0}&client_id={1}&client_secret={2}&redirect_uri={3}" +
"&grant_type={4}", HttpUtility.UrlEncode(authorizationCode),
HttpUtility.UrlEncode(ClientId), HttpUtility
.UrlEncode(ClientSecret),
HttpUtility.UrlEncode(redirectUrl),
*HttpUtility.UrlEncode(authorizationCode)*);
The last parameter should be *HttpUtility.UrlEncode("authorization_code")*
Please see our latest code here:
https://github.com/googleads/googleads-adwords-dotnet-lib/blob/master/src/Common/Lib/OAuth2ProviderForApplications.cs#L135
Thanks,
Ray
On Thursday, May 29, 2014 1:10:54 AM UTC+10, Gonzalo Garcia wrote:
>
> Estimados,
>
> Estoy usando el proyecto de ejemplo que me descargue del sitio.
>
>
> ***********************************************************************************************************
>
> Namespace: Google.Api.Ads.Common.Lib
>
> Class: OAuth2ProviderForApplications
>
> Method: FetchAccessAndRefreshTokens
>
>
> *****************************************************************************
>
> Detalle del métdo:
>
>
>
> public bool FetchAccessAndRefreshTokens(string authorizationCode) {
>
> string redirectUrl = (string.IsNullOrEmpty(RedirectUri)) ?
> OFFLINE_REDIRECT_URL : RedirectUri;
>
>
>
> if (string.IsNullOrEmpty(authorizationCode)) {
>
> throw new ArgumentNullException(CommonErrorMessages
> .OAuth2AuthorizationCodeIsEmpty);
>
> }
>
> ValidateOAuth2Parameter("ClientId", ClientId);
>
> ValidateOAuth2Parameter("ClientSecret", ClientSecret);
>
> string body = string.Format(
> "code={0}&client_id={1}&client_secret={2}&redirect_uri={3}" +
>
> "&grant_type={4}", HttpUtility.UrlEncode(authorizationCode),
>
> HttpUtility.UrlEncode(ClientId), HttpUtility
> .UrlEncode(ClientSecret),
>
> HttpUtility.UrlEncode(redirectUrl), HttpUtility
> .UrlEncode(authorizationCode));
>
> try {
>
> CallTokenEndpoint(body);
>
> } catch (ApplicationException e) {
>
> throw new AdsOAuthException("Failed to get access token." + "\n"+
> e.Message);
>
> }
>
> return true;
>
> }
>
>
> Luego de obtener el código de autorización necesito obtener el “TOKEN”,
> pero estoy recibiendo el siguiente error:
>
>
>
>
>
>
>
> *Failed to get access token. { "error" : "invalid_request",
> "error_description" : "Invalid grant_type:
> 4/47ToZtgnu1fjb00oiz7kRqKU6Bor.MlHJmYy0NAgW3oEBd8DOtNADn98rjAI" }*
>
> ¿Que puede ser?
>
>
> Gracias y saludos,
>
> Gonzalo
>
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.