Git Product home page Git Product logo

sfdc-injector's Introduction

sfdc-injector

This is a CLI console application built with .Net core that publishes events to Salesforce.

Prerequisites

Before using this application, please complete the following software and Salesforce configuration prerequisites.

Software Prerequisites

Please download the following software before using this application.

Salesforce Configuration Prerequisites

Before using this application, you must create a connected app in your Salesforce development org:

  1. From Setup, search for "app manager" in the Quick Find search box.
  2. Click on Apps > App Manager.
  3. Click on New Connected App.
  4. Give your app a Connected App Name, API Name, and Contact Email.
  5. Make sure Enable OAuth Settings is checked.
  6. Make sure Enable for Device Flow is checked.
  7. Make sure the Callback URL is https://login.salesforce.com/services/oauth2/success.
  8. Select the "Access and manage your data (api)" OAuth Scope is selected.
  9. Make sure Require Secret for Web Server Flow is checked.
  10. Take note of your Consumer Key and Consumer Secret. Copy and paste these into App.config.

Usage

Follow the below instructions to use this application on your computer.

  1. Download this repo's .ZIP folder or clone the repo.
  2. From the root directory, build the binary files using the subsequent command. After running the command, you should see two new folders, bin and obj.
    dotnet build
    
  3. From the root directory, create an App.config file to house your API credentials. Paste the subsequent contents into the file, modifying it to suit your credentials. The API version for ApiEndpoint may need to be modified. Note: This file is ignored by Git version control to avoid exposing your credentials.
    <?xml version="1.0" encoding="utf-8" ?>  
    <configuration>  
        <startup>   
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />  
        </startup>  
        <appSettings>
            <add key="LoginEndpoint" value="https://login.salesforce.com/services/oauth2/token" />
            <add key="ApiEndpoint" value="/services/data/v43.0/" />
            <add key="ClientId" value="<YOUR_CLIENT_ID>" />  
            <add key="ClientSecret" value="<YOUR_CLIENT_SECRET>" />  
            <add key="Username" value="<YOUR_USERNAME>" />
            <add key="Password" value="<YOUR_PASSWORD_AND_SECURITY_TOKEN>" />
        </appSettings>  
    </configuration>
    
  4. Run the application using the subsequent command:
    dotnet run
    

Testing

To run the tests, change your directory to SFDCInjector.Tests and use this command:

dotnet test

To generate code coverage report files in a SFDCInjector.Tests/coverage directory, run:

dotnet test -p:CollectCoverage=true -p:CoverletOutputFormat=\"json,lcov\" -p:CoverletOutput='./coverage/'

Resources

Salesforce

C# and .Net

Testing

sfdc-injector's People

Contributors

matthewkosloski avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sfdc-injector's Issues

Make the authentication flag (-a) optional

If it exists, authentication arguments are read from App.config, and these serve as the default and can be optionally overridden by args supplied to the CLI. In other words, if there is a complete App.config, no authentication arguments need to be provided to the CLI under the -a flag.

However the -a flag is still required with blank CLI args (-a ::::).

Thus, to indicate an intention to use the authentication arguments from App.config, you can do:

dotnet SFDCInjector.dll inject -a :::: -e EventClassName:EventFieldPropertyValue

To improve user experience, I propose that the -a flag should be optional and only included if there is an intention to override one or more authentication arguments from App.config.

In other words, I propose that aforementioned usage of the injector be simplified to:

dotnet SFDCInjector.dll inject -e EventClassName:EventFieldPropertyValue

Use a More Secure OAuth Flow

Currently, we are using the Username Password OAuth Flow to connect to Salesforce's REST API.

According to Salesforce,

This method of authentication should only be used in development environments and not for production code. This OAuth authentication flow passes the user’s credentials back and forth. Use this authentication flow only when necessary. No refresh token is issued.

We can potentially use the Device Authentication Flow, which is designed to be used for application with limited input and display capabilities, such as command-line applications.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.