'Github oauth multiple authorization callback URL
I want to work in my localhost and my live domain, there is any way to insert more then one callback to github oauth settings? How we solve this problem?
Solution 1:[1]
I solved this issue by creating a dedicated OAuth application on Github for my local development environment. So I have the following 2 OAuth applications:
My official OAuth application for production
- Client ID:
ABC - Client Secret:
123 - Authorization callback URL:
https://example.com/api/v1/security/oauth/github/callback
- Client ID:
My private OAuth application for development
- Client ID:
XYZ - Client Secret:
456 - Authorization callback URL:
https://localhost/api/v1/security/oauth/github/callback
- Client ID:
When I configure my API in local, I use the ID and secret of the development application (2). And in production I use the ID and secret of my official application (1).
Solution 2:[2]
Instead of using localhost, you can modify your hosts file and point your domain to use 127.0.0.1. On a Mac, open the hosts file located under:
Computer > Macintosh HD > etc
Add the entry for your domain. For example if your domain is mycoolapp.com
127.0.0.1 mycoolapp.com
Just make sure to comment out this line when you want to test using your production server:
#127.0.0.1 mycoolapp.com
Using this solution, you don't need to maintain two separate configurations.
Solution 3:[3]
According their doc, you don't need to register localhost redirect URLs, but it just accepts URLs even if it doesn't match the registered one as long as its host part is localhost.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alexis.Rolland |
| Solution 2 | Johann |
| Solution 3 | tnzk |
