So Please anyone share the code to retrieve the token automatically.
I've been looking at OAuth quite recently myself and I'm struggling!
Anyway - this is not the perfect answer you want - but perhaps it can get you further than I did.
sorry I cant be of more help,
I'll admit I haven't had much occasion to tinker with 0Auth 2.0 Authentication, so I am unfamiliar with that particular topic. I'll see if I can find some information that might be useful though!
Though, I have never used this feature. But, you can give it a try.