As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
Rest API in C# Login says Invalid Credentials, using Kinvey provided login
A
Ashley Swanson
started a topic
almost 7 years ago
I'm trying to login, using the Rest API in C#, but my initial /user/appid/login response says "Unauthorized" and that my credentials are invalid. Here is my code:
string auth = Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes(appID + ":" + appSecret));
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("https://baas.kinvey.com");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Authorization", "Basic " + auth);
client.DefaultRequestHeaders.Add("X-Kinvey-API-Version", "3");
HttpResponseMessage userResp = await client.PostAsync("/user/" + appID + "/login", new StringContent("{\"username\": \"" + user + "\",\"password\": \"" + pass + "\"}", Encoding.UTF8, "application/json"));
I've tested this in the console as well, and the Authorization header is the same, as well as the username and password content. The console returns the expected response, but the code doesn't. I have no idea where I'm going wrong here
Many Thanks
Ashley Swanson
Best Answer
K
Kinvey Support
said
almost 7 years ago
Hi Ashley, I believe the parameters passed into AuthenticationHeaderValue are the scheme (which in this case is basic auth), and the value -- meaning line 5 should be:
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", auth);
Hi Ashley, I believe the parameters passed into AuthenticationHeaderValue are the scheme (which in this case is basic auth), and the value -- meaning line 5 should be:
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", auth);
Ashley Swanson
I'm trying to login, using the Rest API in C#, but my initial /user/appid/login response says "Unauthorized" and that my credentials are invalid. Here is my code:
I've tested this in the console as well, and the Authorization header is the same, as well as the username and password content. The console returns the expected response, but the code doesn't. I have no idea where I'm going wrong here
Many Thanks
Ashley Swanson
Hi Ashley, I believe the parameters passed into AuthenticationHeaderValue are the scheme (which in this case is basic auth), and the value -- meaning line 5 should be:
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstKinvey Support
Hi Ashley, I believe the parameters passed into AuthenticationHeaderValue are the scheme (which in this case is basic auth), and the value -- meaning line 5 should be:
Ashley Swanson
Yep, that did it. Thanks!
-
Why am I getting "SignatureDoesNotMatch" error when uploading a file?
-
Why am I getting an "IncompleteRequestBody" error when sending a DELETE request?
-
Is there a default sort order to collections fetched without an explicit sort query?
-
Is it possible to set ACLs on all users so that only administrators can query for users (without dis
-
Flex SDK
-
Query Bug in Backend?
-
Can analytics data be retrieved via Java SDK or REST?
-
Accesing REST API from a server without a user?
-
What json is required to assign a user group either read/write?
-
LDAP Authorization
See all 120 topics