Created
July 13, 2013 06:52
-
-
Save DevJohnC/5989712 to your computer and use it in GitHub Desktop.
Hosting OAuth services is so easy - based on the new ServiceStack API.
This file contains hidden or 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
| 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) | |
| }; | |
| } | |
| } | |
| } |
This file contains hidden or 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
| 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