<commit_before><?php
/**
 * documentation:  https://github.com/OpenBankProject/OBP-API/wiki/OAuth-1.0-Server
 *
 * register sandbox api : https://apisandbox.openbankproject.com/consumer-registration
 *
 * tested with php version 5.6.1
 *
 *
 */

$baseUrlRealData= 'https://api.openbankproject.com';
$baseUrlSandBox = 'https://apisandbox.openbankproject.com';
$baseUrl        = $baseUrlSandBox;
$apiVersion     = 'v1.2';

session_save_path('/tmp/');
session_start();

$obpApiSettings = array(
	'consumer'  => array(
		'key'   => '',
		'secret'=> '',
	),
	'url' => array(
		'token' => array(
			'request'   => "$baseUrl/oauth/initiate",
			'access'    => "$baseUrl/oauth/token",
		),
		'auth'      => "$baseUrl/oauth/authorize",
		'api'       => "$baseUrl/obp/$apiVersion",
	)
);

$oAuth = new \OAuth( $obpApiSettings['consumer']['key'], $obpApiSettings['consumer']['secret'] );
$oAuth->enableDebug();  // in case of exception debug $oAuth->debugInfo

if ( !isset($_GET['oauthcallback']) || $_GET['oauthcallback'] != 1 || !isset($_GET['oauth_verifier']) ) {
	try {
		oAuthAction($oAuth, $obpApiSettings['url']['token']['request'], $obpApiSettings['url']['auth']);
	} catch ( \OAuthException $ex ) {
		$message = $ex->lastResponse.'_ : _'.$ex->getMessage();
		die($message);
	}
} else {
	if ( !isset($_SESSION['oauth_token_access']) || !isset($_SESSION['oauth_token_secret_access']) ) {
		if ( !isset($_SESSION['oauth_token'])
		     || !isset($_SESSION['oauth_token_secret'])
		     || $_SESSION['oauth_token'] != $_GET['oauth_token'])
		{
			$message = 'Expecting oauth_token and oauth_token_secret, restart oAuth process';
			die($message);
		}

		try {
			$oAuth->setAuthType(OAUTH_AUTH_TYPE_AUTHORIZATION);
			$oAuth->setToken($_SESSION['oauth_token'],$_SESSION['oauth_token_secret']);

			oAuthCallBackAction($oAuth, $obpApiSettings['url']['token']['access'], $_GET['oauth_verifier']);<commit_msg>drop set auth type as OAUTH_AUTH_TYPE_AUTHORIZATION is now \OAuth standard<commit_after><?php
/**
 * documentation:  https://github.com/OpenBankProject/OBP-API/wiki/OAuth-1.0-Server
 *
 * register sandbox api : https://apisandbox.openbankproject.com/consumer-registration
 *
 * tested with php version 5.6.1
 *
 *
 */

$baseUrlRealData= 'https://api.openbankproject.com';
$baseUrlSandBox = 'https://apisandbox.openbankproject.com';
$baseUrl        = $baseUrlSandBox;
$apiVersion     = 'v1.2';

session_save_path('/tmp/');
session_start();

$obpApiSettings = array(
	'consumer'  => array(
		'key'   => '',
		'secret'=> '',
	),
	'url' => array(
		'token' => array(
			'request'   => "$baseUrl/oauth/initiate",
			'access'    => "$baseUrl/oauth/token",
		),
		'auth'      => "$baseUrl/oauth/authorize",
		'api'       => "$baseUrl/obp/$apiVersion",
	)
);

$oAuth = new \OAuth( $obpApiSettings['consumer']['key'], $obpApiSettings['consumer']['secret'] );
$oAuth->enableDebug();  // in case of exception debug $oAuth->debugInfo

if ( !isset($_GET['oauthcallback']) || $_GET['oauthcallback'] != 1 || !isset($_GET['oauth_verifier']) ) {
	try {
		oAuthAction($oAuth, $obpApiSettings['url']['token']['request'], $obpApiSettings['url']['auth']);
	} catch ( \OAuthException $ex ) {
		$message = $ex->lastResponse.'_ : _'.$ex->getMessage();
		die($message);
	}
} else {
	if ( !isset($_SESSION['oauth_token_access']) || !isset($_SESSION['oauth_token_secret_access']) ) {
		if ( !isset($_SESSION['oauth_token'])
		     || !isset($_SESSION['oauth_token_secret'])
		     || $_SESSION['oauth_token'] != $_GET['oauth_token'])
		{
			$message = 'Expecting oauth_token and oauth_token_secret, restart oAuth process';
			die($message);
		}

		try {
			$oAuth->setToken($_SESSION['oauth_token'],$_SESSION['oauth_token_secret']);

			oAuthCallBackAction($oAuth, $obpApiSettings['url']['token']['access'], $_GET['oauth_verifier']);
{'fraction_non_alphanumeric': 0.20835522858644245, 'fraction_numerical': 0.004203888596952181, 'mean_word_length': 4.929906542056075, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4567516', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1333, 'n_words': 191}