public static async Task <GrantTokenResponse> GrantToken(RocketMatterInstance Instance, string AuthCode, string AppSecret) { var Client = new HttpClient(); var Response = await Client.Send <GrantTokenResponse>(Instance.UrlPrefixSecure("/Authentication.svc/json/GrantToken"), new { grant_type = "code", code = AuthCode, client_secret = AppSecret, }).DefaultAwait(); return(Response); }
public static async Task Main(string[] args) { var App = new FasterLawApiClientApplicationInfo(); var Listener = new MC.RocketMatter.Authentication.Embedded.EasyListenerAuthenticationProvider(new Authentication.Embedded.ListenerAuthenticationProviderOptions() { Application = App }); var Provider = await Listener.AuthenticateOnce(); System.Diagnostics.Process.Start(Provider.Provider.EndpointAuthorizationUrl); var Auth = await Provider.Result; if (Auth == null) { Console.WriteLine("Unable to Authenticate"); } else { var Domain = await RocketMatterApi.GetDomainForInstall(Auth.Install); var Instance = new RocketMatterInstance(Domain, Auth.Install); var Grant = await RocketMatterApi.GrantToken(Instance, Auth.Code, App.Secret); var ApiClient = new MC.RocketMatter.RocketMatterApi(Instance, Grant.Access_Token); var AllContacts = await ApiClient.Contacts_List(); var AllMatters = await ApiClient.Matters_List(); var AllInvoices = await ApiClient.Invoices_List(); var ClientData = new ClientData { Code = "1234", Name = "Added Via API", LastName = "Last Name1", }; } }
public RocketMatterApi(RocketMatterInstance Instance, string Authorization) { this.Instance = Instance; HttpClient.DefaultRequestHeaders.Add("Authorization", Authorization); }