OAuth 2.0 and OpenID Connect APIs can be used for both authentication and authorization so the security implications of getting the implementation correct, we strongly encourage you to take advantage of a pre-written library or service. Authenticating users properly is important to their and your safety and security, and using well-debugged code written by others is generally a Best Practice.
OAuth 2.0 Threat Model and Security Configurations