From 13331746795548fb898437417c618283bc0077e1 Mon Sep 17 00:00:00 2001 From: Alan Rynne Date: Thu, 30 Mar 2023 14:15:42 +0200 Subject: [PATCH] fix(core): Parse the redirect URL correctly to retrieve the access code (#2362) Or throw an exception with clear meaning. --- Core/IntegrationTests/Fixtures.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Core/IntegrationTests/Fixtures.cs b/Core/IntegrationTests/Fixtures.cs index 4187d15587..0c1ddfb50e 100644 --- a/Core/IntegrationTests/Fixtures.cs +++ b/Core/IntegrationTests/Fixtures.cs @@ -1,5 +1,6 @@ using System.Net.Mime; using System.Text; +using System.Web; using Newtonsoft.Json; using Speckle.Core.Api; using Speckle.Core.Credentials; @@ -66,7 +67,10 @@ public static async Task SeedUser() throw new Exception($"Cannot seed user on the server {Server.url}", e); } - var accessCode = redirectUrl.Split("?access_code=")[1]; + var uri = new Uri(redirectUrl); + var query = HttpUtility.ParseQueryString(uri.Query); + + var accessCode = query["access_code"] ?? throw new Exception("Redirect Uri has no 'access_code'."); var tokenBody = new Dictionary() { ["accessCode"] = accessCode,