oauth 2.0 – Power BI Auth2.0 integration with Autodesk BIM360/Forge

I am trying to make a custom power BI data connector to connect Autodesk BIM360/Forge.
I have setup auth2.0 authentication as per the power BI github connect sample.The program runs fine in the debug environment in visual studio. But when running the same thing from inside power bi it freezes at authorization step.

Power BI Desktop Freezing in this page-
enter image description here

Visual Studio showing authentication generated-
enter image description here

Connector-https://mnc5d-my.sharepoint.com/:u:/p/sourav_ganguli/ETg4BHsRRMxGgPvnh5-z4l0BzDim1LBmz91vsSeaWDsysA?e=Oaak4j

Code-

 '''
    // This file contains your Data Connector logic
section PQExtension1;

client_id="VsuX1PRxOl0GQw4O52FNF9DsBgYHqPzN";
client_secret ="O0HHUVoxQFiom6XO";
Scope="data:read";
redirect_uri ="http://localhost:9000";
AuthorizeUrl="https://developer.api.autodesk.com/authentication/v1/authorize?";
TokenUri="https://developer.api.autodesk.com/authentication/v1/gettoken";

windowHeight=720;
windowWidth=720;





[DataSource.Kind="PQExtension1", Publish="PQExtension1.Publish"]
shared PQExtension1.Contents = (url as text) =>
    let
        source = Json.Document(Web.Contents(url))
    in
        source;


// Data Source Kind description
PQExtension1 = [
    Authentication = [
        OAuth = [
            StartLogin = StartLogin,
            FinishLogin = FinishLogin
            ]
       // Implicit = []
    ],
    Label = Extension.LoadString("DataSourceLabel")
];

// Data Source UI publishing description
PQExtension1.Publish = [
    Beta = true,
    Category = "Other",
    ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },
    LearnMoreUrl = "https://powerbi.microsoft.com/",
    SourceImage = PQExtension1.Icons,
    SourceTypeImage = PQExtension1.Icons
];

PQExtension1.Icons = [
    Icon16 = { Extension.Contents("PQExtension116.png"), Extension.Contents("PQExtension120.png"), Extension.Contents("PQExtension124.png"), Extension.Contents("PQExtension132.png") },
    Icon32 = { Extension.Contents("PQExtension132.png"), Extension.Contents("PQExtension140.png"), Extension.Contents("PQExtension148.png"), Extension.Contents("PQExtension164.png") }
];


StartLogin = (resourceUrl, state, display) =>
        let
            AuthorizeUrl = AuthorizeUrl & Uri.BuildQueryString([
                client_id = client_id,
                client_secret = client_secret,
                response_type="code",
                scope = Scope,
                state = state,
                redirect_uri = redirect_uri])
        in
            [
                LoginUri = AuthorizeUrl,
                CallbackUri = redirect_uri,
                WindowHeight = windowHeight,
                WindowWidth = windowWidth,
                Context = null
            ];

FinishLogin = (context, callbackUri, state) =>
    let
        Parts = Uri.Parts(callbackUri)[Query]
    in
        TokenMethod(Parts[code]);

TokenMethod = (code) =>
    let
        Response = Web.Contents(TokenUri, [
            Content = Text.ToBinary(Uri.BuildQueryString([
                client_id = client_id,
                client_secret = client_secret,
                grant_type="authorization_code",
                code = code,
                redirect_uri = redirect_uri])),
            Headers=[#"Content-type" = "application/x-www-form-urlencoded",#"Accept" = "application/json"]]),
        Parts = Json.Document(Response)
    in
        Parts;
    '''

Read more here: Source link