- Simple wrapper of the Uber API
- You need an app.
- All methods are async.
- All methods return an instance of UberResponse where T is the serialized Uber response data. An UberResponse also contains an Error property which will contain information in the event of an error being returned by the underlying API.
- Contains an UberSandboxClient for submitting requests against the Uber API sandbox.
Note I built this in my spare time for a bit of fun, if you've found any bugs or you'd like to contribute please get involved!
When making requests on behalf of a user via OAuth, ensure you understand scopes.
The following methods can use client OR server authentication:
- GetProductsAsync
- GetPriceEstimateAsync
- GetTimeEstimateAsync
- GetPromotionAsync
The following methods require client (OAuth) authentication:
- GetUserActivityAsync
- GetUserProfileAsync
- RequestAsync
- GetRequestDetailsAsync
- GetRequestMapAsync
- CancelRequestAsync
var uberClient = new UberClient(AccessTokenType.Server, serverToken, clientId, clientSecret, baseUri);
var uberClient = new UberClient(AccessTokenType.Server, serverToken, clientId, clientSecret, baseUri);
The web application example demonstrates how to authenticate users and execute each method.
// Create authentication client
var authClient = new UberAuthenticationClient(clientId, clientSecret);
// Generate authorize URL - If you don't specify scope, state or redirect URI then app defaults will be used
var authorizeUrl = authClient.GetAuthorizeUrl();
// Once authorized, swap authorization code for an access token
var accessToken = await authClient.GetAccessTokenAsync(code, "http://your-redirect-uri.com");
// You can now make requests on behalf of the user
var authClient = new UberAuthenticationClient(clientId, clientSecret);
var url = uberClient.GetAuthorizeUrl();
var authClient = new UberAuthenticationClient(clientId, clientSecret);
var accessToken = await uberClient.GetAccessTokenAsync(code, "http://your-redirect-uri.com");
var authClient = new UberAuthenticationClient(clientId, clientSecret);
var accessToken = await uberClient.RefreshAccessTokenAsync(refreshToken, "http://your-redirect-uri.com");
var authClient = new UberAuthenticationClient(clientId, clientSecret);
var revoked = await uberClient.RevokeAccessTokenAsync(accessToken);
var uberClient = new UberClient(AccessTokenType.Server, serverToken);
var products = await uberClient.GetProductsAsync(startLatitude, startLongitude);
var uberClient = new UberClient(AccessTokenType.Server, serverToken);
var prices = await uberClient.GetPriceEstimateAsync(startLatitude, startLongitude, endLatitude, endLongitude);
var uberClient = new UberClient(AccessTokenType.Server, serverToken);
var times = await uberClient.GetTimeEstimateAsync(startLatitude, startLongitude);
var uberClient = new UberClient(AccessTokenType.Server, serverToken);
var promotion = await uberClient.GetPromotionAsync(startLatitude, startLongitude, endLatitude, endLongitude);
var uberClient = new UberClient(AccessTokenType.Client, clientToken);
var userActivity = await uberClient.GetUserActivityAsync(0, 50);
var uberClient = new UberClient(AccessTokenType.Client, clientToken);
var userProfile = await uberClient.GetUserProfileAsync();
var uberClient = new UberClient(AccessTokenType.Client, clientToken);
var request = await uberClient.RequestAsync(productId, startLatitude, startLongitude, endLatitude, endLongitude);
var uberClient = new UberClient(AccessTokenType.Client, clientToken);
var requestDetails = await uberClient.GetRequestDetailsAsync(requestId);
var uberClient = new UberClient(AccessTokenType.Client, clientToken);
var request = await uberClient.GetRequestMapAsync(requestId);
var uberClient = new UberClient(AccessTokenType.Client, clientToken);
var cancel = await uberClient.CancelRequestAsync(requestId);