OAUTH2 works well in localhost(with sub.domain.com) but fails with "401 url not authorized" in server

237 Views Asked by At

after a lot of work and learning. I have developed an authentication service OAUTH2 in flask w / gunicorn, uses the module requests-oauthlib and have reverse proxy to nginx, all within docker-compose(alpine images), as I am new in this I want it with all the flavors :). It works perfectly in my local environment, which uses a subdomain "oauth2.example.com:5000", I receive from the api the token and json with the user data in the last step, everything is ok, but when it passes to the production environment(https://oauth2.example.com) it fails with a message "401 unauthorized for url". The api service that I'm using for this test is Linkedin

what I've already tried?

  • Use other hosting machine
  • Check the authorization url
  • Use postman to verify that the received token(in local and production) is valid
  • A test outside docker
  • check callback urls
  • Maybe I need to register my domain in somewhere (Linkedin)?

thanks for your help buddies.

1

There are 1 best solutions below

0
On

Well, after some days of research and check everything with my code is ok, I founded the problem, and I dont know is my fault but it's seems to appear the linkedin profile url: "https://api.linkedin.com/v1/people/~:(first-name)" doens't work in production enviroments, I dont know how, but when I use a sub.domain.com in my local enviroment works well,I receive the json with the user data and the valid token, I thought was related to the domain localhost.

The solution to my problem was change the profile url to: "https://api.linkedin.com/v2/me/" Now I'm recieving user data and tokens in my production enviroment, but I still have limited access to other info, I need to aply for api access here https://business.linkedin.com/marketing-solutions/marketing-partners/become-a-partner/marketing-developer-program#get-started.