breeze - Get Access Token with BreezeSharp -


i need use entityquery in breezesharp access token breeze webapi

i have class called tokenresponsemodel deserializing json server follows:

using newtonsoft.json; namespace cmis.integration.common {     class tokenresponsemodel     {         [jsonproperty("access_token")]         public string accesstoken { get; set; }          [jsonproperty("token_type")]         public string tokentype { get; set; }          [jsonproperty("expires_in")]         public int expiresin { get; set; }          [jsonproperty("username")]         public string username { get; set; }          [jsonproperty(".issued")]         public string issuedat { get; set; }          [jsonproperty(".expires")]         public string expiresat { get; set; }     } } 

i have following code run:

entityquery query=entityquery.from("token",new tokenresponsemodel()). withparameters(new dictionary<string,object>{{"grant_type","password"},{"username","my_username"},{"password","my_password"}});  entitymanager mng = new entitymanager(baseurl);  var tokenobject = await query.execute(mng); 

when run it, error. requires metadata not there "/token" method on server.

how can call breezesharp.

with restsharp can follows:

restrequest request = new restrequest("/token", method.post);  request.addparameter("grant_type", "password"); request.addparameter("username", "my_username"); request.addparameter("password", "my_password");  restclient client = new restclient(baseurl); var response = client.execute<accesstoken>(request); 

and works fine. thanks

more explanation: want need result breeze server json format. don't want mapped objects on client. example case authenticating user using token method. know how parse json myself. want breeze bring result call below:

string baseurl = "http://myserver_url/nhifservice/"; entityquery query = entityquery.from<string>("token").withparameters(new new dictionary<string, object> { { "grant_type", "password" }, { "username", "my_username" }, { "password", "my_password" } });  entitymanager mng = new entitymanager(baseurl); var tokenobject = await query.execute(mng); 

i want able because return anonymous objects server not have match on client or server. can breese sharp allow me without caring metadata. or how can supress metadata fetching.

thank you.

after going through breezesharp source code came solution doing wanted. guys @ ideablade have created dataservice class enables returning raw json server without caring metadata. here how did it:

string token = await authenticationhelper.getaccesstoken();  string baseurl = "http://my_server_url/appname/breeze/my_controller/";  dataservice ds = new dataservice(baseurl); string resourcepath = string.format("getcarddetails?cardno={0}", cardnotextedit.editvalue); ds.httpclient.defaultrequestheaders.add("authorization", "bearer " + token); string result=await ds.getasync(resourcepath); 

congratulation guys breeze sharp awesome.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -