The Salesforce sandbox environment has a different base URL from the production environment. Instead of https://login.salesforce.com/, you log in to https://test.salesforce.com/. When you authenticate a Salesforce instance, you must pass a siteAddress
query parameter with the sandbox URL when getting the redirect URL. See Authenticate Through API.