Azure AD authentication with Rails and devise

I have a rails app with devise configured and mongodb database. I want to configure Microsoft azure AD for authentication. When the user enters my project url and the user is not signed in, it should redirect to azure AD’s sign in page and when the credentials are correct, it should redirect back to my application. I followed this blog to achieve my requirement. Even then, I stuck with callback errors. Can someone suggest a good blog to follow?