I got it to work.
Use Client ID and Client Secret in the developer area, for some reason they have username and password listed.
Here is what I have as a final if anybody needs help with it in the future:
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
class UPSController extends Controller
{
public function __invoke(){
$ups_id = config('ups.id');
$ups_secret = config('ups.secret');
$credentials = base64_encode("$ups_id:$ups_secret");
$url = 'https://wwwcie.ups.com/security/v1/oauth/token';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'accept: application/json',
"x-merchant-id: $ups_id",
"Authorization: Basic $credentials",
'Content-Type: application/x-www-form-urlencoded',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'grant_type=client_credentials');
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response);
}
}