DataConnectors icon indicating copy to clipboard operation
DataConnectors copied to clipboard

Diagnostics.Trace with OAuth crashes visual studio

Open alazyworkaholic opened this issue 2 years ago • 3 comments

I've had no luck with OAuth so I thought I'd try Diagnostics.Trace.

If I wrap the StartLogin function like so:

StartLogin =  Diagnostics.Trace(
	TraceLevel.Information,
	"Made it here",
	() => Cinchy.StartLogin,
	true
),

and run in the Visual Studio Power Query SDK, the SDK's built-in login screen appears, I select OAuth authentication (ignore the Access Token field that appears), press login, and a few seconds later Visual Studio crashes.

If I wrap Cinchy.StartLogin like so:

Cinchy.StartLogin = (Host, state, display) => let 
	Result = [ 
		LoginUri = Host & "/cinchysso/connect/authorize?" & Uri.BuildQueryString([
			client_id="PowerBI",
			redirect_uri="https://oauth.powerbi.com/views/oauthredirect.html",
			response_mode="form_post",
			response_type="id_token token",
			scope="openid profile id roles offline_access",
			nonce=Text.AfterDelimiter(Text.From(Number.Random()), ".")
		]),
	CallbackUri = "https://oauth.powerbi.com/views/oauthredirect.html",
	WindowHeight = 720,
	WindowWidth = 1024,
	Context = null
]
in Diagnostics.Trace(TraceLevel.Information, "Made it here", () => Result, true);

I just get a pop-up window stating "Error. Login failed. Details: Object reference not set to an instance of an object."

If I disable all tracing, a window of size {WindowHeight, WindowWidth} shows up with the service's login page. However, I get a 400 error after I provide the credentials so something seems to be wrong with my FinishLogin function, but I can't see what I'm passing in because Diagnostics.Trace doesn't work.

alazyworkaholic avatar Aug 20 '21 18:08 alazyworkaholic