-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from markogrady/master
Changes to the api to allow settings to be store in secrets and azure
- Loading branch information
Showing
10 changed files
with
137 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Options; | ||
using Xero.Api.Example.MVC.Authenticators; | ||
using Xero.Api.Example.MVC.Helpers; | ||
using Xero.Api.Infrastructure.OAuth; | ||
|
||
namespace Xero.Api.Example.MVC.Controllers | ||
{ | ||
public class HomeSettingController : Controller | ||
{ | ||
private IMvcAuthenticator _authenticator; | ||
private ApiUser _user; | ||
private ApplicationSettings _applicationSettings; | ||
public HomeSettingController(IOptions<ApplicationSettings> applicationSettings) | ||
{ | ||
_user = XeroApiHelper.User(); | ||
_applicationSettings = applicationSettings.Value; | ||
_authenticator = XeroApiHelper.MvcAuthenticator(_applicationSettings); | ||
} | ||
|
||
public IActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
|
||
public ActionResult Connect() | ||
{ | ||
var authorizeUrl = _authenticator.GetRequestTokenAuthorizeUrl(_user.Identifier); | ||
|
||
return Redirect(authorizeUrl); | ||
} | ||
|
||
public ActionResult Authorize(string oauth_token, string oauth_verifier, string org) | ||
{ | ||
var accessToken = _authenticator.RetrieveAndStoreAccessToken(_user.Identifier, oauth_token, oauth_verifier); | ||
if (accessToken == null) | ||
return View("NoAuthorized"); | ||
|
||
return View(accessToken); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@model Xero.Api.Infrastructure.Interfaces.IToken | ||
|
||
@{ | ||
ViewBag.Title = "Authorize"; | ||
Layout = "~/Views/Shared/_Layout.cshtml"; | ||
} | ||
|
||
<h2>Authorized</h2> | ||
<h3>Token Key: @Model.TokenKey</h3> | ||
<h3>Token Secret: @Model.TokenSecret</h3> | ||
<h3>Expires At: @Model.ExpiresAt</h3> | ||
|
||
@if (!string.IsNullOrEmpty(@Model.Session)) | ||
{ | ||
<h3>Session: @Model.Session</h3> | ||
} | ||
|
||
|
||
@Html.ActionLink("Organisation Details", "Index", "Organisation") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@{ | ||
ViewBag.Title = "Connect"; | ||
Layout = "~/Views/Shared/_Layout.cshtml"; | ||
} | ||
|
||
<h2>Connect</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@{ | ||
ViewBag.Title = "Index"; | ||
Layout = "~/Views/Shared/_Layout.cshtml"; | ||
} | ||
|
||
|
||
|
||
<a id="btnConnect" href="@Url.Action("Connect", "Home")">Connect to Xero</a> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@{ | ||
ViewBag.Title = "Not Authorized"; | ||
Layout = "~/Views/Shared/_Layout.cshtml"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters