I realized this question has been previously asked but with little in the way of example code, so I am asking again but with at least a little bit of direction.
Afte
Regarding Richard Collette answer, be careful that using his method if you want to use Analytics API in READONLY mode, the correct way to use it is:
string Scope = "analytics.readonly"
and not
string Scope = AnalyticsService.Scopes.AnalyticsReadOnly.ToString().ToLower()
as he seems to tell that there is a bug. In fact, the bug is that the .toString() method returns analyticsreadonly and NOT analytics.readonly which is the way that Google likes. That's it.