Skip to content

Commit

Permalink
Dynamically generate the oauth_callbackurl from the current web app
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Barratt committed Jul 30, 2012
1 parent c807b95 commit cde24e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 3 additions & 2 deletions source/XeroApi.MvcWebApp/Controllers/ConnectController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ public ActionResult Index()


// Determine the callback uri to use - this must match the domain used when the application was registerd on http://api.xero.com
Uri callbackUri = new Uri(ConfigurationManager.AppSettings["XeroApiCallbackUrl"]);
var callbackUri = new UriBuilder(Request.Url.Scheme, Request.Url.Host, Request.Url.Port, Url.Action("Callback"));


// Call: GET /oauth/RequestToken
RequestToken requestToken = oauthSession.GetRequestToken(callbackUri);
RequestToken requestToken = oauthSession.GetRequestToken(callbackUri.Uri);

Trace.WriteLine("OAuth Request Token: " + requestToken.Token);
Trace.WriteLine("OAuth Request Secret: " + requestToken.TokenSecret);
Expand Down
3 changes: 1 addition & 2 deletions source/XeroApi.MvcWebApp/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
Use 'https://api-partner.network.xero.com/' for partner apps
-->
<add key="XeroApiBaseUrl" value="https://api.xero.com/api.xro/2.0/" />
<add key="XeroApiCallbackUrl" value="http://127.0.0.1:51306/Connect/Callback" />

<!-- OAuth Signing Certificate - needed for private and partner apps -->
<add key="XeroApiOAuthCertificateFindType" value="FindBySerialNumber" />
Expand All @@ -30,7 +29,7 @@
<system.web>

<!-- SessionState needs to be enabled as the OAuth Access token is stored inside it -->
<sessionState mode="InProc" timeout="60" />
<sessionState mode="InProc" timeout="60" />

<compilation debug="true" targetFramework="4.0">
<assemblies>
Expand Down

0 comments on commit cde24e9

Please sign in to comment.