Skip to content

ryanjayford/OAuth2_DotnetCore_MVC5_SampleApp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sample Banner

OAuth2_DotnetCore_MVC5_SampleApp

DotNet Core MVC5 Sample app using .NET Standard SDK

The Intuit Developer team has written this OAuth 2.0 Sample App in .Net Core(C#) MVC5 to provide working examples of OAuth 2.0 concepts, and how to integrate with Intuit endpoints. It uses the Owin Context to save the user cookies for the session. More details can be read here and here

Getting Started

Before beginning, it may be helpful to have a basic understanding of OAuth 2.0 flow. There are plenty of tutorials and guides to get started with OAuth 2.0. Check out the docs on https://developer.intuit.com/

PreRequisites

  1. Visual Studio 2015 or above
  2. Microsoft.Net.Compilers 2.10.0
  3. .Net Core 2.2

Setup

Clone this repository/Download the sample app.

Configuring your app

All configuration for this app is located in appsettings.json. Locate and open this file.

We will need to update the below items items:

  1. ClientId
  2. ClientSecret
  3. RedirectURL
  4. Environment
  5. DBConnectionString
  6. QBOBaseURL

Client Credentials

Once you have created an app on Intuit's Developer Portal, you can find your credentials (Client ID and Client Secret) under the "Keys" tab. You will also find a section to enter your Redirect URL here.

Redirect URI

You'll have to set a Redirect URI in both 'web.config' and the Developer Portal ("Keys" section). With this app, the typical value would be https://localhost:47331/connect/index, unless you host this sample app in a different way (if you were testing HTTPS, for example or changing the port).

Scopes

This sample app requires Accounting scope, please choose this if creating a new app.

DBConnectionString

This sample app requires database connectivity to store the tokens(AccessToken and RefreshToken) used for doing our API calls and also update the token with new tokens when the token expires.

If you are using Localdb Instance then create a database in it using the below steps:

  1. Open Visual Studio -> Tools -> Connect to Database...
  2. Select Microsoft SQL Server and click Continue.
  3. Enter (localdb)\mssqllocaldb as the Server Name.
  4. Enter master as the Database Name and click OK.
  5. The master database is now displayed under Data Connections in Server Explorer.
  6. Right-click on the database in Server Explorer and select New Query.
  7. Copy the script from Tokens.sql into the query editor and select Execute.
  8. Once the database is created successfully, Open Visual Studio -> Tools –> NuGet Package Manager –> Package Manager Console and run the following command: Scaffold-DbContext “Server=(localdb)\mssqllocaldb;Database=Tokens;Trusted_Connection=True;” Microsoft.EntityFrameworkCore.SqlServer - OutputDir Models

If you are using an existing database,then update the connectionstring with your database connection in your appsettings.json

Run your app!

After setting up both Developer Portal and your appsettings.json, run the sample app.

Connect To QuickBooks

This flow goes through authorization flow where QBO user logs in and authorizes your app. At the end of this process, the app will end up with tokens and if you are a first time user it will create new tokens in the database and if you a recurring user and if your tokens are expired then it will update the database.

QBO API request

Access tokens from Connect to QuickBooks flow are used to make a Customer and Invoice request which allows to create a customer and invoice in your company. If any tokens are expired, then it refresh those tokens based on the refresh token.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 93.5%
  • HTML 5.3%
  • Other 1.2%