You should use the Credential Manager API for authentication and the Authorization Client API for authorization requests (Migration Guide).
If you are making authorization requests and using the Authorization Client API, you can get the auth code by calling the getServerAuthCode() method of the AuthorizationResult.
This is the recommended approach that does not require specifying a redirect URI.