9 Responses to “Signing In To Google AdSense”

  1. You are rocking dude, really a nice post, I will write about
    this soon with trackback on my own blog of Adsense Help too.

  2. Chris says:


    I found this information
    extremely useful and managed to use it as a base for an Adsense checking app. It was all working fine till today! Something has stopped working – I presume google may have changed something?

    you have any ideas what?


  3. Naki says:

    I tried to run you code and I get the following exception:

    System.ArgumentException was unhandled
    Message=”parsing \”GA3T=(?.*)\” – Unrecognized grouping construct.”
    at System.Text.RegularExpressions.RegexParser.ScanGroupOpen()
    at System.Text.RegularExpressions.RegexParser.ScanRegex()
    at System.Text.RegularExpressions.RegexParser.Parse(String re, RegexOptions op)
    at System.Text.RegularExpressions.Regex..ctor(String pattern, RegexOptions options, Boolean useCache)
    at System.Text.RegularExpressions.Regex.Match(String input, String pattern)
    at Microsoft.Samples.MediaCatalog.Form1.GetAdSense() in C:\Work\Manager\Form1.cs:line 260
    at Microsoft.Samples.MediaCatalog.Form1..ctor(Boolean bPost) in C:\Work\Manager\Form1.cs:line 335
    at Microsoft.Samples.MediaCatalog.Program.Main(String[] args) in C:\Work\Manager\Program.cs:line 31
    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()

    Any idea?


  4. jack says:

    I can’t do work this code. Please help me!

  5. Felix says:

    Google changed their login structure, and this code does not work anymore. Please advise on proper modifications. A PHP version (WITH changes made) has been posted here: and you if scroll down to the comments you can see the specific changes – but I am PHP-retarded. Can anybody offer advice on how to modify THIS code? Thanks

  6. alexmipego says:


    I’ve updated the code to fix the bogus regex expressions (wordpress editor striped some bits from them) and also to fix the code since Google changed the signin process slightly. For the more interrested, Google now has 2 cookies/hidden vars instead of 1, the code is almost the same though.

    Let me know if there are still problems.

  7. Jason says:

    I also am getting an unrecognized grouping construct error:

    Server Error in ‘/’ Application.
    parsing “url='(?.*)'” – Unrecognized grouping construct.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentException: parsing “url='(?.*)'” – Unrecognized grouping construct.

    Source Error:

    Line 53:
    Line 54: response = webclient.DownloadData(checkCookieUri);
    Line 55: newUrl = Regex.Match(HttpUtility.HtmlDecode(Encoding.UTF8.GetString(response)), “url='(?.*)'”).Groups[“url”].Value;
    Line 56:
    Line 57: if (String.IsNullOrEmpty(newUrl))


  8. alexmipego says:

    Its the dam wordpress editor, any text similar to ? just gets the striped out and in this case its the grouping constructors… Anyway, I’ve fixed it like I did for the ga3t and galx so you can just check the updated line 30.

  9. Masterpesho says:

    Two additions:
    – Loop through all the hidden elements and add the values to the postData

    string postData = String.Empty;

    foreach (string input in ExtractTagArray(response, “input”))
    if (input.IndexOf(“hidden”) > 0)
    postData += ((postData.Length > 0) ? “&” : “”) +
    GetValue(input, “name”) + “=” + HttpUtility.UrlEncode(GetValue(input, “value”));

    postData += “&Email=” + HttpUtility.UrlEncode(username) +
    “&Passwd=” + HttpUtility.UrlEncode(password);

    – Remove line 29

    The two extra methods I am using:

    private ArrayList ExtractTagArray(string source, string tag)
    ArrayList Results = new ArrayList();

    string Pattern = String.Format(@”]*>”, tag);
    Regex regex = new Regex(Pattern, RegexOptions.IgnoreCase);

    foreach (Match CurMatch in regex.Matches(source))

    return Results;

    private string GetValue(string source, string tagName)
    Regex regex = new Regex(tagName + “\\s*=\\s*((?:\\\”(?[^\\\”]*)\\\”)|(?:'(?[^’]*)’)|(?[^\\s|>]*))”, RegexOptions.IgnoreCase);

    return regex.IsMatch(source) ? regex.Match(source).Groups[“value”].Value : String.Empty;

Leave a Reply

For spam filtering purposes, please copy the number 4227 to the field below: