Reputation: 551
So, I've been working on this a couple days and I'm missing something. I'm trying to create a Xamarin
forms app that connects to a cloud accounting package using OAuth2
authentication. I've been working through the examples from here. But I just can't get the redirect working. Most likely something simple, but I'm not seeing or understanding
I'm created my authenticator as per the example, setting the redirect url
to https://com.myproject.myapp/oauth2redirect.
var authenticator = new OAuth2Authenticator(
<ClientId>,
null,
"openid profile email accounting.transactions accounting.settings offline_access",
new <AuthoriseationEndpoint>,
new Uri("https://com.myproject.myapp/oauth2redirect"),
new <TokenEndpoint>,
null,
true);
Then, I'm created a new activity
in my Android project with the intentFilter
[Activity(Label = "CustomUrlSchemeInterceptorActivity", NoHistory = true)]
[IntentFilter(new[] { Android.Content.Intent.ActionView },
Categories = new[] { Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable },
DataSchemes = new[] { "com.myproject.myapp" },
DataPath = "/oauth2redirect")]
public class CustomUrlSchemeInterceptorActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
var uri = new Uri(Intent.Data.ToString());
// Load redirectUrl page
AuthenticationState.Authenticator.OnPageLoading(uri);
Finish();
// Create your application here
}
}
When I run my app, the login screen pops up as expected. My app is registered okay with the cloud application fine but the redirect doesn't work. I just get a browser error saying the site can't be reached. Server IP address could not be found DNS_PROBE_FINISHED_NXDOMAIN
Upvotes: 1
Views: 886
Reputation: 14956
try to change
var authenticator = new OAuth2Authenticator(
<ClientId>,
null,
"openid profile email accounting.transactions accounting.settings offline_access",
new <AuthoriseationEndpoint>,
new Uri("https://com.myproject.myapp/oauth2redirect"),
new <TokenEndpoint>,
null,
true);
to
var authenticator = new OAuth2Authenticator(
<ClientId>,
null,
"openid profile email accounting.transactions accounting.settings offline_access",
new <AuthoriseationEndpoint>,
new Uri("com.myproject.myapp:/oauth2redirect"),
new <TokenEndpoint>,
null,
true);
You could not add https://
to your custom redirect url after you define a Schemes. Note that only a single /
can appear after the scheme component.
you could refer to Redirect URL
Upvotes: 0