Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed some issues with the demo client #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion class/Db.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Db {
private static $instance;

private function __construct() {
$this->pdoInstance = new PDO("mysql:host=localhost;dbname=oauthProvider","oauth","oauth");
$this->pdoInstance = new PDO("mysql:host=localhost;dbname=oauth","oauth","oauth");
$this->pdoInstance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->pdoInstance->exec("set names 'utf8'");
}
Expand Down
4 changes: 2 additions & 2 deletions class/Provider.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Provider{
private $consumer;
private $oauth_error;
private $user;
private $authentification_url = "http://localhost/OAuthProviderExample/oauth/login.php";
private $authentification_url = "http://workspace.local/OAuthProviderExample/oauth/login.php";

public static function createConsumer(){
$key = sha1(OAuthProvider::generateToken(20,true));
Expand Down Expand Up @@ -138,7 +138,7 @@ public function checkToken($provider){
if(is_null($token)){ // token not found
return OAUTH_TOKEN_REJECTED;
} elseif($token->getType() == 1 && $token->getVerifier() != $provider->verifier){ // bad verifier for request token
return OAUTH_VERIFIER_INVALID;
return VERIFIER_TOKEN_INVALID;
} else {
if($token->getType() == 2){
/* if this is an access token we register the user to the provider for use in our api */
Expand Down
2 changes: 1 addition & 1 deletion client/apicall.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$oauth_client = new Oauth("key","secret");
$oauth_client->enableDebug();
$oauth_client->setToken($_POST['token'],$_POST['token_secret']);
$oauth_client->fetch("http://localhost/OAuthProviderExample/oauth/api/user");
$oauth_client->fetch("http://workspace.local/OAuthProviderExample/oauth/api/user");
echo "API RESULT : ".$oauth_client->getLastResponse();
} catch (OAuthException $E){
echo $E->debugInfo;
Expand Down
4 changes: 2 additions & 2 deletions client/callback.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
if(isset($_REQUEST['oauth_token'])&&isset($_REQUEST['oauth_verifier'])){
if(isset($_REQUEST['oauth_token'])&&isset($_REQUEST['verifier_token'])){
if(isset($_POST['oauth_token'])){
try{
$oauth_client = new Oauth("key","secret");
$oauth_client->enableDebug();
$oauth_client->setToken($_POST['oauth_token'],$_POST['oauth_token_secret']);
$info = $oauth_client->getAccessToken("http://localhost/OAuthProviderExample/oauth/access_token",null,$_POST['oauth_verifier']);
$info = $oauth_client->getAccessToken("http://workspace.local/OAuthProviderExample/oauth/access_token",null,$_POST['verifier_token']);
echo "<h1>Congrats !</h1>";
echo "<strong>AccessToken</strong> ".$info['oauth_token']."<br />";
echo "<strong>AccessToken Secret</strong> ".$info['oauth_token_secret'];
Expand Down
2 changes: 1 addition & 1 deletion client/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
$oauth_client = new Oauth("key","secret");
$oauth_client->enableDebug();
try {
$info = $oauth_client->getRequestToken("http://localhost/OAuthProviderExample/oauth/request_token?oauth_callback=http://localhost/OAuthProviderExample/client/callback.php");
$info = $oauth_client->getRequestToken("http://workspace.local/OAuthProviderExample/oauth/request_token?oauth_callback=http://workspace.local/OAuthProviderExample/client/callback.php");
echo "<h1>We have a request token !</h1>";
echo "<strong>Request token</strong> : ".$info['oauth_token']."<br />";
echo "<strong>Request token secret</strong> : ".$info['oauth_token_secret']."<br />";
Expand Down
2 changes: 1 addition & 1 deletion oauth/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function __autoload($name){
if(is_object($user)){
$request_token->setVerifier(Provider::generateVerifier());
$request_token->setUser($user);
header("location: ".$request_token->getCallback()."?&oauth_token=".$_REQUEST['oauth_token']."&oauth_verifier=".$request_token->getVerifier());
header("location: ".$request_token->getCallback()."?&oauth_token=".$_REQUEST['oauth_token']."&verifier_token=".$request_token->getVerifier());
} else {
echo "User not found !";
}
Expand Down