Skip to content

Oauth2 authentication

Hatzegopteryx edited this page Jan 25, 2019 · 5 revisions

Common parameters

token = 'SOA2nNQvB663vs0igU3H22brWHtUibJT'; This is needed to mitigate server-side attacks, because the app_code might be exposed in the future in Javascript. All requests to oauth2/set_access (from infusionsoft campaigns) and oauth2/get_access (user authentication) will include this parameter.

app_code = 'ROWZkx9yBbV2Qffz1IchbNyMnR4591T4'; Each app has an unique 32-bytes app_code

Please keep the above values in an .env file in the application's root directory.

ouath2_url = https://operationalhub.linuxserv.space/oauth2/get_access'; for authentication

ouath2_url = https://operationalhub.linuxserv.space/oauth2/set_access'; for infusionsoft campaigns

Oauth2 authentication

Send an http post to the operational hub via curl:

$post_data = array(

`'token'    => <token here>,`

`'app_code' => <app_code here>,`

`'email'    => <user's email>,`

`'password' => <user's password>,`

);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, <Oauth2 url here>);

curl_setopt($ch, CURLOPT_POST, TRUE);

curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));

curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

$response = curl_exec($ch);

curl_close($ch);

$responseData = json_decode($response, true);

if(isset($responseData['status']) && $responseData['status'] === 'SUCCESS')

{

`// save session`

}

Clone this wiki locally