`In php i am trying to generate a online meeting url using microsoft teams.
We tried using the Microsoft graphs API, and were able to generate the token. However while submitting the request, we get a 403 Forbidden Error. We have registered our application in Azure and also given the required API permissions.
my API permssions also my tenant having authorized license
$auth_url = "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/authorize";
$params = [
'client_id' => $clientId,
'response_type' => 'code',
'redirect_uri' => $redirectUri,
'response_mode' => 'query',
'scope' => 'offline_access OnlineMeetings.ReadWrite User.Read',
'state' => '884766', // Optional: Prevent CSRF attacks
];
$authUrl = $auth_url . '?' . http_build_query($params);
then in auth page
$clientId = TEAM_CLIENT_ID;
$redirectUri = REDIRECT_URI;
$tenantId = TENANT_ID;
$clientSecret = CLIENT_SECRET;
$tokenEndpoint = "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token";
// Step 3: Exchange authorization code for an access token
$client = new Client();
$response = $client->post($tokenEndpoint, [
'form_params' => [
'grant_type' => 'authorization_code',
'client_id' => $clientId,
'client_secret' => $clientSecret,
'code' => $authorizationCode,
'redirect_uri' => $redirectUri,
'scope' => 'user.read onlineMeetings.ReadWrite offline_access',
]
]);
$responseData = json_decode($response->getBody(), true);
$accessToken = $responseData['access_token'];
$refreshToken = $responseData['refresh_token'];
$expiresIn = $responseData['expires_in'];
untill this i am getting the response.
$response = $client->post('https://graph.microsoft.com/v1.0/me/onlineMeetings', [
'headers' => [
'Authorization' => 'Bearer ' .$accessToken,
'Content-Type' => 'application/json',
],
'json' => [
'subject' => 'Test Meeting',
'startDateTime' => '2024-08-04T15:00:00Z',
'endDateTime' => '2024-08-04T16:00:00Z',
],
'debug' => true // Enable Guzzle's debug output
]);
$data = json_decode($response->getBody(), true);
I am getting an error Guzzle HTTP error: Client error: POST https://graph.microsoft.com/v1.0/me/onlineMeetings
resulted in a 403 Forbidden
response: {“error”:{“code”:”Forbidden”,”message”:”9024: Exception of type ‘Microsoft.Skype.SkypeCast.SchedulerWebRole.BusinessLogic.Teams.Common.Exceptions.TeamsMeetingProcessorException’ was thrown.. Would anyone please help out here as I am behind delivery.
`
teresa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.