Hi @Ahmed Abassi
If you want to access other tenants, you must configure your application as a multi-tenant application.
Then, run the admin consent URL in the browser and have the global administrator of the target tenant log in and accept the permissions. After that, your multi-tenant application will be added as an enterprise application to the target tenant and will have the permissions you granted it in the original tenant. Finally, you will be able to use this application to access the resources of the target tenant.
https://login.microsoftonline.com/{tenant id of the target tenant}/adminconsent?client_id={client id}
Hope this helps.
If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.