Created
February 17, 2012 21:52
-
-
Save jgeurts/1855675 to your computer and use it in GitHub Desktop.
AuthSub authentication for Google api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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