Blaze.Controllers.OAuthService.GetTokens C# (CSharp) Method

GetTokens() public method

public GetTokens ( string code ) : LaunchpadTokens
code string
return LaunchpadTokens
        public LaunchpadTokens GetTokens(string code)
        {
            var request = new RestRequest("/authorization/token", Method.POST);
            request.AddParameter("client_id", clientId);
            request.AddParameter("type", "web_server");
            request.AddParameter("client_secret", clientSecret);
            request.AddParameter("redirect_uri", GetRedirectUri());
            request.AddParameter("code", code);
            var client = new RestClient(LaunchpadBaseUrl);
            IRestResponse<LaunchpadTokens> reply = client.Execute<LaunchpadTokens>(request);
            if (reply.StatusCode == HttpStatusCode.OK)
            {
                return reply.Data;
            }
            throw new Exception(string.Format("Error retrieving Launchpad tokens. Status: {0} ({1}) Content: {2}. Error Message: {3}. Error Exception: {4}", reply.StatusCode, reply.StatusDescription, reply.Content, reply.ErrorMessage, reply.ErrorException));
        }

Usage Example

Example #1
0
 public ActionResult LaunchpadCallback(string code)
 {
     if (!string.IsNullOrEmpty(code))
     {
         var reply = oAuthService.GetTokens(code);
         oAuthService.AssignCookies(reply, Response);
         return(RedirectToAction("Chat"));
     }
     return(RedirectToAction("Index"));
 }
All Usage Examples Of Blaze.Controllers.OAuthService::GetTokens