-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
57 lines (33 loc) · 1.62 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
-------------------------------
A C# library for the oDesk API
-------------------------------
Maintained by Daniel Sim ([email protected]), contributions welcome.
~ Overview ~
Currently demonstrates how to authenticate a user using OAuth, then query the oDesk API on their behalf.
It's a work in progress with only two working API methods. If you use this library and add other methods, please contribute your source to the project.
Uses the DotNetOpenAuth package installable through NuGet.
I've substituted the InMemoryTokenManager in my production code with one using Entity Framework.
~ To be done ~
- Split API methods out, add more to cover the whole API
- Example project
- Separate unit test project (currently within my own project)
...all help appreciated!
~ Example usage ~
Simple example using MVC and a custom token manager based on the entity framework:
public virtual ActionResult Index(ODeskAuthModel m)
{
var tokenManager = new ODeskTokenManager();
var odesk = new WebConsumer(ODeskConsumer.ServiceDescription, tokenManager);
var accessTokenResponse = odesk.ProcessUserAuthorization();
if (accessTokenResponse != null) //Authorised
{
m.AccessToken = accessTokenResponse.AccessToken;
m.Result = ODeskConsumer.GetTeams(odesk, m.AccessToken).ToString();
}
else if (m.AccessToken == null)
{
// If we don't yet have access, immediately request it.
ODeskConsumer.RequestAuthorization(odesk);
}
return View(m);
}