Tuesday, April 24, 2012

[YouTube-API] Re: Urgent - well known app with 200,000+ users suddenly can't upload via oAuth2

Hi Dan,


On Apr 24, 8:20 am, Dan S <dsie...@gmail.com> wrote:
> [SNIP]
> So far, it seems that YouTube has, without warning, started returning a 62
> character OAuth2 authorization code, instead of the previous 30 character
> OAuth2 code.
>
> Since there is no clear "best practices" way on how to universally parse
> out the authorization code -- and asking users to copy paste it themselves
> is absurd, we have instead always parsed it by finding a 30 character
> string in the browser title.

It's been a while since I used the YouTube Desktop Oauth2 flow, but I
believe the document title is encoded in the same way as a URL query
string, e.g. dlg.HTMLPageTitle == "code=A...&error=B..."

There is a best practice for dealing with that: use a standard library
for parsing query strings into dictionaries and then look up the
expected code by name.

For example:

NameValueCollection qscoll =
HttpUtility.ParseQueryString(dlg.HTMLPageTitle);
String code = qscoll["code"];

Hope that helps.

>
> tokens = dlg.HTMLPageTitle.Split(new[] {' ', '='});
> foreach (string ss in tokens)
>                         {
>                             if (ss.Length == 30)
>                             {
>                                 AuthorizationCode = ss;
>                                 break;
>                             }
>                         }
>
> Our temporary fix and replacement is this:
>  if (tokens.Length > 2)
>                         {
>                             AuthorizationCode = tokens[2];
>                         }
>

--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.

No comments:

Post a Comment