Skip to content

Instantly share code, notes, and snippets.

@jgeurts
Created February 17, 2012 21:52
Show Gist options
  • Save jgeurts/1855675 to your computer and use it in GitHub Desktop.
Save jgeurts/1855675 to your computer and use it in GitHub Desktop.
AuthSub authentication for Google api
public ActionResult Auth()
{
const string scope = "https://www.google.com/analytics/feeds/";
var next = Url.FullPath("~/home/authresponse");
var url = AuthSubUtil.getRequestUrl(next, scope, false, true);
return Redirect(url);
}
public ActionResult AuthResponse(string token)
{
var sessionToken = AuthSubUtil.exchangeForSessionToken(token, null);
Settings settings;
using (RavenSession.Advanced.DocumentStore.DisableAggressiveCaching())
{
settings = RavenSession.Load<Settings>(Settings.DefaultId);
}
if (settings == null)
settings = new Settings
{
Id = Settings.DefaultId
};
settings.SessionToken = sessionToken;
RavenSession.Store(settings);
return RedirectToAction("Config");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment