Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Commands/Base/PnPConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ internal static PnPConnection CreateWithACSAppOnly(Uri url, string realm, string
if (realm == null)
{
realm = GetRealmFromTargetUrl(url);

if(realm == null)
{
throw new Exception($"Could not determine realm for the target site '{url}'. Please validate that a site exists at this URL.");
}
}

if (url.DnsSafeHost.Contains("spoppe.com"))
Expand Down Expand Up @@ -772,7 +777,7 @@ internal static string GetRealmFromTargetUrl(Uri targetApplicationUri)
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "");

var response = client.GetAsync(targetApplicationUri + "/_vti_bin/client.svc").GetAwaiter().GetResult();
if (response == null)
if (response == null || response.StatusCode == System.Net.HttpStatusCode.NotFound)
{
return null;
}
Expand Down