Skip to content
This repository has been archived by the owner on Mar 7, 2019. It is now read-only.

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

Open
paranoid-android opened this issue May 16, 2018 · 2 comments
Assignees
Labels
more information needed indicates a question doesn't have enough information to be answered properly question

Comments

@paranoid-android
Copy link

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
Copy link
Owner

kenakamu commented Jun 5, 2018

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

@baywet baywet added question more information needed indicates a question doesn't have enough information to be answered properly labels Aug 21, 2018
@saikiran2603
Copy link

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 ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
more information needed indicates a question doesn't have enough information to be answered properly question
Projects
None yet
Development

No branches or pull requests

4 participants