.net - Creating C# OAuth 2 client -


i'm creating own oauth 2.0 client in c#. work, i'm wondering if function authorization correct , safe. should data encryption? i've seen oauth clients doing hmacsha1 encryption. sorry i'm new things. here goes code:

public string getaccesstoken() {     string uri = "http://192.168.1.89:8080/oauth/token";     client.defaultrequestheaders.authorization = new authenticationheadervalue(         "basic", convert.tobase64string(system.text.asciiencoding.ascii.getbytes(         string.format("{0}:{1}", client_id, client_secret))));      client.baseaddress = new uri(uri);      var parameters = new dictionary<string, string>();     parameters["password"] = password;     parameters["username"] = username;     parameters["grant_type"] = grant_type;     parameters["scope"] = scope;     parameters["client_id"] = client_id;     parameters["client_secret"] = client_secret;      var response = client.postasync(uri, new formurlencodedcontent(parameters)).result;     console.writeline((response.statuscode.tostring()));     string resultcontent = response.content.readasstringasync().result;     console.writeline(resultcontent);      string s = "access_token\":\"";     string token = resultcontent.substring(resultcontent.indexof(s) + s.length, tokenlength);     return token; } 


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -