kenakamu / UCWA2.0-CS

C# library for UCWA 2.0
MIT License
24 stars 13 forks source link

TestClient: InvalidOperationException: You need to initialize and subscribe the event before starting. #53

Open paranoid-android opened 6 years ago

paranoid-android commented 6 years ago

Hello,

This API looks great! However, I've had trouble using it.

I just cloned this repo and attempted to run the TestClient.

First, there were two minor compilation issues. Once I fixed those, I was able to run the TestClient. When prompted for my username, I entered: [username]@[customer].onmicrosoft.com. I then put in my password. At this point, when the client.Initialize call on line 94 was executed, I received the following error:

ArgumentException: 'authority' Uri should have at least one segment in the path (i.e. https://<host>/<path>/...)
Parameter name: authority

I then decided to change line 94 to:

client.Initialize("[customer].onmicrosoft.com");

When I ran the app again, I entered just my [username], not the '@' and everything after it. I then then entered my password. This time, I received the following error:

InvalidOperationException: You need to initialize and subscribe the event before starting.

I also tried running the Univeral WIndows app. However, it crashed when I clicked the "Login" button.

kenakamu commented 6 years ago

hm, it did still work to me. Can you send me your sample if you don't mind for troubleshooting with temporary password if it is okay? kenakamumicrosoft.com

saikiran2603 commented 5 years ago

Hi , I am facing the same error .. it works when i run the testclient , but i am building a Console app in .net core , I acquired the token via the web service , and passed it on but it fails at client.initialize .. i think its unable to create an application ..

here i used below code to aquire the token ,

HttpClient client = new HttpClient(); string tokenEndpoint = "https://login.microsoftonline.com/" + tenantid + "/oauth2/token"; //string tokenEndpoint = "https://login.microsoftonline.com/@navigateconsulting.in/oauth2/token"; var body = "resource=" + resourceid + "&client_id=" + client_id + "&grant_type=password&username=" + username + "&password=" + password + ""; var stringContent = new StringContent(body, Encoding.UTF8, "application/x-www-form-urlencoded");

        var result = await client.PostAsync(tokenEndpoint, stringContent).ContinueWith<string>((response) =>
        {
            return response.Result.Content.ReadAsStringAsync().Result;
        });

        JObject jobject = JObject.Parse(result);

        var token = jobject["access_token"].Value<string>();

        return token;

i tried to initilize passing the tenant ID , directly.

client.Initialize("2f892c02-6a40-43d0-840d-fXXXXXXXXX").Wait(); client.SignIn(availability: Availability.Online, supportMessage: true, supportAudio: false, supportPlainText: true, supportHtmlFormat: false, phoneNumber: "", keepAlive: true).Wait();

seems i am missing something .. could you please help me with it ?