I have tried the below
XeroConfiguration xeroConfig = new XeroConfiguration();
xeroConfig.ClientId = "****";
xeroConfig.ClientSecret = "****";
xeroConfig.CallbackUri = new Uri("http://localhost"); //default for standard webapi template
xeroConfig.Scope = "openid profile email files accounting.transactions accounting.contacts offline_access";
var client2 = new XeroClient(xeroConfig, httpClientFactory);
var test = client2.BuildLoginUri();
return Redirect(client2.BuildLoginUri());
After redirection it is giving below error Error code: 500 Error: unauthorized_client: Invalid redirect_uri
It is because you have registered your app in the Authorization Server using a different redirect URI and in the above you are using a different redirect URI which will be validated by the Authorization Server and on mismatch, it is throwing you the Error.
You have to register your app with the Redirect URI that you will be using
Ex: If your app is running in http://localhost:6500
and your redirect URI to receive the token and process is http://localhost:6500/login
. You have to provide this value to the Authorization Server.
ex: The setting would look like
xeroConfig.CallbackUri = new Uri("http://localhost:6500/login")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.