Skip to content

Instantly share code, notes, and snippets.

@DevJohnC
Created July 13, 2013 06:52
Show Gist options
  • Select an option

  • Save DevJohnC/5989712 to your computer and use it in GitHub Desktop.

Select an option

Save DevJohnC/5989712 to your computer and use it in GitHub Desktop.
Hosting OAuth services is so easy - based on the new ServiceStack API.
using ServiceStack.ServiceInterface;
namespace OAuth.Services
{
[TwoLegged]
[ThreeLegged]
public class Friends : OAuth.Service
{
public object Get(DTOs.Friends friends)
{
return new DTOs.FriendsResponse
{
Friends = UserRepository.GetFriends(User.UserId)
};
}
}
}
using System;
using System.Web;
using System.Web.Mvc;
namespace OAuth.Controllers
{
public class TestController : Controller
{
//
// GET: /Test/
public string Index()
{
var api = new OAuthJsonServiceClient("http://localhost/api/", "CONSUMER_KEY", "CONSUMER_SECRET");
var users = api.Get<DTOs.FriendsResponse>(new DTOs.Friends(){ Username = "jcarruthers" });
var ret = "";
foreach (var user in users.Friends)
{
ret += user + ", ";
}
ret = ret.Substring(0, ret.Length - 2);
return ret;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment