c# - How can i create StateClient object in LoginController using service url or microsoft app credentials? -


i working on bot framework technology, in 1 of project want create state client object using service url or microsoft credentials in logincontroller.cs

this code wrote in logincontroller.cs, it's working in bot emulator after published bot , added skype it's not working.

 //[httpget, route("api/{userid}/authorize")]     [httpget, route("api/{userid}/token")]     public async system.threading.tasks.task<httpresponsemessage> authorize(string userid, string code)     {         authenticationcontext ac = new authenticationcontext("https://login.windows.net/common/oauth2/token/");         clientcredential cc = new clientcredential(constants.constants.adclientid, constants.constants.adclientsecret);         authenticationresult ar = await ac.acquiretokenbyauthorizationcodeasync(code, new uri(constants.constants.apibasepath + userid + "/token"), cc, "https://api.office.com/discovery/");         if (!string.isnullorempty(ar.accesstoken))         {            // var stateclient = new stateclient(new uri("http://localhost:9000/"));             // var stateclient = new stateclient(new uri("http://skype.botframework.com/"));             //var microsoftappcredentials = new microsoftappcredentials(appid: "ace15a7e-b7f6-4776-a6a3-a58c0314bd01", password: "x7bs9hjt0sksbu6z9kgw1fb");             //var stateclient = new stateclient(new uri("http://skype.botframework.com/"),microsoftappcredentials,addjwttokenrefresher:true);             //var stateclient = new stateclient(microsoftappcredentials);              var stateclient = new stateclient(new uri("https://apis.skype.com/"));             //var stateclient = new stateclient(new uri("https://api.slack.com/"));              if (stateclient != null)             {                 var userid = userid.replace("-", ":");                 var getdata = await stateclient.botstate.getuserdataasync(constants.constants.botid, userid);                  //var getdata = await client.b.getuserdataasync(constants.constants.botid, userid);                 getdata.data = ar.serialize();                 getdata.etag = "*";                 var foo = await stateclient.botstate.setuserdataasync(constants.constants.botid, userid, getdata);                  //var foo = await client.bots.setuserdataasync(constants.constants.botid, userid, getdata);             }             //return request.createresponse(foo);             var response = request.createresponse(httpstatuscode.moved);             response.headers.location = new uri("/loggedin.html", urikind.relative);             return response;         }         else             return request.createresponse(httpstatuscode.unauthorized);      } 

please tell how resolve above problem.

-pradeep

the url state client service following, independent of channel.

        this.baseuri = new uri("https://state.botframework.com"); 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -