Skip to content

Commit

Permalink
Issue #10 put the correct URL (the authorise URL)
Browse files Browse the repository at this point in the history
  • Loading branch information
judgej committed May 13, 2019
1 parent 12884a4 commit 59adbd1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# Xero API
# Xero API Client

API package for Xero authenticated access, PSR-7, PSR-15, PSR-18.
API package for Xero authenticated access.
Leverages PSR-7, PSR-17 and PSR-18.

Handles the OAuth 1.0a requests, and token renewals for the *partner application*.
It does this by offering a decorated PSR-18
It does this by offering a decorated PSR-18 client.

Provides support for the authentication flow to capture the OAuth 1.0a tokens.

Features include:

* Support for *Partner Application* only at present.
* Automatic token renewal by time (including guard time) or on an expired token.
* Callback to the application for persistence of the OAuth1 token credentails
when they gety renewed.
* Automatic token renewal of a token by its local age, or on an expiry flagged by
the remote Xero API.
* Hook to the application for persistence of the OAuth1 token credentails
when they get renewed. This keeps the burden of renewals away from the application.

## Simple Usage

Expand Down
14 changes: 7 additions & 7 deletions src/Oauth1/Authorise.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ public function getTemporaryToken()
'oauth_callback' => $this->getConfigItem('callback_uri'),
];

if ($this->getConfigItem('redirect_on_error')) {
// This should force a cancel to come back to the consumer
// site, but I'm not sure it is working.

$queryParameters['redirectOnError'] = 'true';
}

// Construct URI.

$oauth1Endpoint = $this->getOauth1Endpoint();
Expand Down Expand Up @@ -105,6 +98,13 @@ public function authoriseUrl(OauthTokenInterface $temporaryToken)
$queryParameters['oauth_token'] = $oauthToken;
}

if ($this->getConfigItem('redirect_on_error')) {
// This should force a cancel to come back to the consumer
// site, but I'm not sure it is working.

$queryParameters['redirectOnError'] = 'true';
}

$oauth1Endpoint = $this->getOauth1Endpoint();

$redirectUserUri = $oauth1Endpoint->getRedirectUserUri()
Expand Down
20 changes: 20 additions & 0 deletions src/Oauth1/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,16 @@ public function withOauthProblem(string $oauthProblem): self
return (clone $this)->setOauthProblem($oauthProblem);
}

/**
* Undocumented, some results come back with an "error"
* GET parameter. Map them onto an OAuth error.
*/
public function setError(string $error): self
{
$this->oauthProblem = $error;
return $this;
}

/**
* Get/set/with OAuth reason.
*/
Expand All @@ -424,6 +434,16 @@ public function withOauthProblemAdvice(string $oauthProblemAdvice): self
return (clone $this)->setOauthProblemAdvice($oauthProblemAdvice);
}

/**
* Undocumented, some results come back with an "error_description"
* GET parameter. Map them onto an OAuth error.
*/
public function setErrorDescription(string $errorDescription): self
{
$this->oauthProblemAdvice = $errorDescription;
return $this;
}

/**
* @return bool true if the object contains an OAuth error
*/
Expand Down

0 comments on commit 59adbd1

Please sign in to comment.