static void Main(string[] args) { // Please paste your App Id and Shared Secret from your application profile on https://developer.deere.com string clientKey = "Your application's 'App ID' from developer.deere.com"; string clientSecret = "Your application's 'Shared Secret' from developer.deere.com"; var oauthWorkflowExample = new OAuthWorkFlow(); // We currently support oAuth 1.0. You can dig in to the authentication code for an example using the // open source DevDefined.OAuth libraries. var apiCredentials = oauthWorkflowExample.Authenticate(clientKey, clientSecret); // Now let's inject the credentials into our rest client and make some API calls // Check out the OAuthSignedRestClient source for how to use the oAuth token to sign requests var oauthRestClient = new OAuthSignedRestClient(apiCredentials); var apiCatalog = GetApiCatalog(oauthRestClient); var apiClient = new ApiClient(apiCredentials); var organizationsLink = apiCatalog.links.Single(link => link.rel == LinkRel.organizations.ToString()); var organizations = apiClient.GetAllUsingPagination <Organization>(organizationsLink.uri).ToList(); // Examples of downloading all files using Detags, and uploading a new file new FilesApiExamples(apiClient).MakeFilesApiCalls(organizations); // How to get all fields for an organization, optionally embedding clients, farms, and boundaries new FieldsApiExamples(apiClient).MakeFieldsApiCalls(organizations); // Want to get operational data for a field? // In reality we'd probably call the Fields API and use its output to get FieldOperations for each Field. var fields = new List <Field>(); new FieldOperationsApiExamples(apiClient).MakeFieldOperationsApiCalls(fields); }
static void Main(string[] args) { OAuthWorkFlow of = new OAuthWorkFlow(); /* please plugin your App Id and Secret from https://developer.deere.com app profile into ApiCredentials.cs CLIENT constructor * * Once access token and token secret are generated, please plug in the values from output console window into ApiCredentials.cs TOKEN constructor * * Once the App ID, secret, Token and Token Secret are updated in ApiCredentials.cs run the program to get Fleet details example * * The Access Token and Token Secret are good for an year. If the token has expired, please clear the TOKEN constructor and regenerate a token and secret with the above process outlined. */ string ConsumerKey = ApiCredentials.CLIENT.key; string ConsumerSecret = ApiCredentials.CLIENT.secret; string OAuthToken = ApiCredentials.TOKEN.token; string OAuthTokenSecret = ApiCredentials.TOKEN.secret; if (ConsumerKey.Equals("Replace with App id from developer.deere.com") || ConsumerSecret.Equals("Replace with secret for the App from developer.deere.com")) { System.Diagnostics.Debug.WriteLine("\n Please replace ApiCredentials.CLIENT with the App ID and secret of your App from developer.deere.com" + " and rerun the program to generate OAuth Token and Token Secret \n"); return; } else if (OAuthToken.Equals("") || OAuthToken.Equals("token printed in console output after running the oauth worflow code") || OAuthTokenSecret.Equals("") || OAuthTokenSecret.Equals("token secret printed in console output generated after running the oauth workflow code")) { of.retrieveOAuthProviderDetails(); of.getRequestToken(); of.authorizeRequestToken(); of.exchangeRequestTokenForAccessToken(); System.Diagnostics.Debug.WriteLine("\n Please replace ApiCredentials.TOKEN with the Token and Token Secret printed in the output window" + " and rerun the program to get the Fleet Details \n"); return; } else { FleetInfo fi = new FleetInfo(); fi.retrieveFleetDetails(); } }