Runkeeper (HealthGraph) API REST client in .NET Core 2.0.
NOTE: The current project is in development phase, so it is not fully functional. November 2017
Currently, only the source code is available for download from this repository.
git clone https://github.com/yorchideas/HealthGraphAPI.git
In the future, this can be installed using NuGet, by running the following command in the Package Manager Console:
PM> Install-Package HealthGraphAPI
- Ensure you already registered your application in the Runkeeper Partner Portal.
- Ensure your project references the
HealthGraphAPI
. - Perform authorization/authentication flow to request the user to allow access to its Runkeeper information.
using HealthGraphAPI;
namespace HealthGraphAPI.Examples
{
public class HealthGraphAPIAuthExample
{
private readonly HealthGraphAuth auth;
private readonly HealthGraphClient client;
private HealthGraphToken token;
public HealthGraphAPIAuthExample()
{
auth = new HealthGraphAuth
{
ClientID = "<<your application client_id>>",
ClientSecret = "<<your application client_secret>>",
RedirectUri = new Uri("<<your application redirect_uri>>")
};
client = new HealthGraphClient(auth);
}
private void PerformAuthFlow()
{
var authorizeUri = client.BuildAuthorizeUri();
// TODO: Use a WebBrowser to navigate the URL retrieved in authorizeUri, it can be done manually or by using any WebBrowser control in any supported client-platform (WinForms, WPF, UWP, Xamarin), sign-in to your Runkeeper account and allow the application to access, when finished, the WebBrowser will redirect to the RedirectUri especified, copy the URL and paste in the next part
var redirectUri = new Uri("<<paste here the URL redirected from WebBrowser>>");
var result = client.HandleAuthorization(redirectUri); // TODO: When running in a WebBrowser control, use the 'OnNavigation' event (accordingly to the control)
if (result.Status = HealthGraphAuthStatus.Auhtorized && client.Token != null)
{
// TODO: Authorization/authentication flow was successful, now you can store the client.Token values, to use in futher examples
token = client.Token;
}
else
{
// TODO: Handle error
}
}
}
}
TODO
TODO