title: How to configure API key & API secret in Laravel?
body: <p>I have been working on a Laravel project that provides online education to students. I wanted to use Zoom services of video conferencing so that the teacher can connect with their students through video conference. Following the API reference documentation, I have registered an app with Zoom. I got an API key and API secret along with an access token by following the documentation.</p>
  <p>I am sending subsequent requests to post/fetch data from Zoom, but I have been getting an error message like this:</p>
  <pre><code>Client error: `POST https://api.zoom.us/v2/accounts` resulted in a `400 Bad Request` response: {&quot;code&quot;:200,&quot;message&quot;:&quot;Invalid api key or secret.&quot;}  
  </code></pre>
  <p>I am sending API key and API secret in header but still getting the same error. Probably I am doing something wrong with the requesting process or may be something else, I don't know. I have searched on internet how to integrate Zoom with Laravel app but couldn't find any helpful information.</p>
  <p>Can anybody please help me to figure out what I am doing wrong? Can someone provide me some helpful resources about Zoom API integration with Laravel?</p>
  <pre><code>class AccountsController extends Controller
  {
      public function createAccount(Request $request) {
  
          $client_id = env('CLIENT_ID');
          $client_secret = env('CLIENT_SECRET');
  
          $content = &quot;grant_type=client_credentials&amp;client_id=$client_id&amp;client_secret=$client_secret&quot;;
          $token_url=&quot;https://zoom.us/oauth/token&quot;;
  
          $curl = curl_init();
  
          curl_setopt_array($curl, array(
  
              CURLOPT_URL =&gt; $token_url,
              CURLOPT_SSL_VERIFYPEER =&gt; true,
              CURLOPT_RETURNTRANSFER =&gt; true,
              CURLOPT_POST =&gt; true,
              CURLOPT_POSTFIELDS =&gt; $content
          ));
  
          $data = curl_exec($curl);
          curl_close($curl);
          $result = json_decode($data);
  
          $access_token = $result-&gt;access_token;
          $client = new \GuzzleHttp\Client();
  
          $api_key = env('API_KEY');
          $api_secret = env('API_SECRET');
  
          $response = $client-&gt;request('POST', 'https://api.zoom.us/v2/accounts', [
              'headers' =&gt; [
                  'apikey' =&gt; $api_key,
                  'apisecret' =&gt; $api_secret,
                  'Accept' =&gt; 'application/json',
                  'Content-Type' =&gt; 'application/json',
                  'Authorization'     =&gt; 'Bearer '. $access_token
              ],
              'form_params' =&gt; [
                  'first_name' =&gt; $request-&gt;first_name,
                  'last_name' =&gt; $request-&gt;last_name,
                  'email' =&gt; $request-&gt;email,
                  'password' =&gt; $request-&gt;password,
              ],
          ]);
          $response = $response-&gt;getBody()-&gt;getContents();
          dd($response);
      }
  }
  </code></pre>
  <p>This is the json response against this API call:</p>
  <pre><code>{
    &quot;id&quot;: &quot;string&quot;,
    &quot;owner_id&quot;: &quot;string&quot;,
    &quot;owner_email&quot;: &quot;string&quot;,
    &quot;created_at&quot;: &quot;string&quot;
  }
  </code></pre>