A cloud-based identity and access management service for securing user authentication and resource access
@AdityaPareekQuickLaunchIdentity-4855, Thank you for reaching out. The works with Graph API Explorer is because the token issued to the request generated from the Graph API explorer is for the user and in your app, when you try to request the token you are requesting it in application's context (i.e for the application) as you are using client_credentials flow there.
You would need to implement the Authorization-Code Grant flow or Password Owner Resource Grant Flow in this case to get your job done. Choose the flow that suits best for your application's design as both these flows are for users, in other words using both these flows you can get a token issued to your user.
Hope this helps.
Do let us know if this helps and if there are any more queries around this, please do let us know so that we can help you further. Also, please do not forget to accept the response as Answer; if the above response helped in answering your query.