Q: How to solve Missing grant_type parameter value in API with Laravel and cURL I am creating a web site to view Results that gives me from a API. So, First of all I generated Access token form the Postman and then I have included it to the API header. Then I tried to generate Access token with cURL. But, it always gives me this below error.

{#480 ▼   +"error_description": "Missing grant_type parameter value"
  +"error": "invalid_request" }

How can I solve this ??
Here is the Controller that I used for generate the Access token. (AccessToken.php)
public function authticate(){

        $tokengen = "base64(clientid:clientsecret)";

        $url = 'http://api.gate.com.:8254/token?=';
        $tokengenheaders = array(
            'grant_type: client_credential',
            'Content-Type: application/x-www-form-urlencoded',
            'Authorization: Basic '.$tokengen

        );

        $ch2 = curl_init();
        curl_setopt($ch2, CURLOPT_URL, $url);
        curl_setopt($ch2, CURLOPT_HTTPHEADER, $tokengenheaders);
        curl_setopt($ch2, CURLOPT_POST, true);
        curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);

        $tokenid = curl_exec($ch2);
        curl_close($ch2);

        return $tokenid;

    }

Here is controller that has the API.(SLAPIControoler.php)
public function SearchSchedule(Request $request)
    {
        $StartCity = $request->input('StartCity');
        $EndCity = $request->input('EndCity');
        $StartDate = $request->input('StartDate');
        $StartTime = $request->input('StartTime');
        $EndTime = $request->input('EndTime');
        $Lang = 'en';

        $auth = new AccessToken();
        $authtoken = json_decode($auth->authticate());
//        dd($authtoken); die();

        $url = "http://api.gate.com:8253/bus/1.0/searchTrain?startStationID=".$StartCity."&endStationID=".$EndCity."&searchDate=".$StartDate."&startTime=".$StartTime."&endTime=".$EndTime."&lang=".$Lang;

        $headers2 = array(
            'Authorization: Bearer ' . $authtoken,
            'Content-Type: application/json'
        );

        $ch2 = curl_init();
        curl_setopt($ch2, CURLOPT_URL, $url);
        curl_setopt($ch2, CURLOPT_HTTPHEADER, $headers2);
        curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
        //curl_setopt($ch2, CURLOPT_POSTFIELDS, json_encode($decodedjsonarray));
        // echo(curl_exec($ch2));

        $results = json_decode(curl_exec($ch2));
        curl_close($ch2);

        dd($results); die();

        //$GetCities = DB::table('airports')->get();
        //$resultsets = array("data" => $results, "totaltravlers" => $AllThePassengers, "faredetails" => $revalidationarray, "GetCities" => $GetCities);

        //return view('Metro.reviewpage')->with('resultsets', $resultsets);

    }

