A jive instance support Basic and Oauth 2.0 for authentication. To access jive first register as a client with jive and install a add on. Using installed add on get client id and secret key.
Let we explain procedure step by step. For this we use jive sandbox account.
Step 1: Login in you jive sandbox account. Than use this Jive Oauth 2.0 Client Builder link to create an Add on.
Enter your server redirect url where you can receive the auth code. Mention the add on title and description and must upload a icon for the add on. After this download the Add on.
Step 2: In your sandbox jive on account. Click on Add on option to upload the downloaded Add on. Upload you package.
After successfully installed add on you can get Client id and Secret key. Use this credential to access the jive on rest api.
Note: To access jive instance for third party, must Enable the External Contributors option for particular add on.
Step 3: Now we can go for Authorization code. You need to mention Add on redirect url, which you use while creating an add on and Client Id. Use this url to get the auth code:
https://client.application.com/oauth2/redirect?code=
Use below PHP file to get the authorize code from jive rest api v3
1 2 3 4 5 6 7 8 9 10 |
<?php header("Location: https://sandbox.jiveon.com/oauth2/authorize?client_id=****Use Client Id Here***&response_type=code&redirect_uri=Use Add On mentioned Redirect Url Here"); exit; ?> |
When you run above code, redirect to jive login page. Use sandbox login access and allow the app.
Step 4: After getting auth code, go for access token. Use this curl method to get access token.
curl -u ‘<CLIENT_ID>:<CLIENT_SECRET>’ -d ‘code <AUTHZ_CODE>&grant_type=authorization_code&client_id=<CLIENT_ID>’ https://<JIVE-
URL>/oauth2/token
Check below curl php code for access token. Use your add on client id and secret key here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<?php $code = $_GET['code']; $handle = curl_init('https://sandbox.jiveon.com/oauth2/token'); $data = array('grant_type' => 'authorization_code', 'client_id' => '****Use Client Id Here***', 'code' => $code); curl_setopt($handle, CURLOPT_POST, true); curl_setopt($handle, CURLOPT_USERPWD, "****Use Client Id Here***".":"."****Use Client Secret Here***"); curl_setopt($handle, CURLOPT_POSTFIELDS, $data); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); $resp = curl_exec($handle); echo "<pre>"; print_r($resp); curl_close($handle); ?> |
After follow above steps you can get authorization for Jive Rest Api v3. Now you can use access token for access jive api method. Their are many People, content and document etc. method available.
Jive rest api has bearer type of access token. Pass access token and content type in header php curl code for particular api call.