API Login working?

  • Question
  • Updated 2 years ago
Yesterday I started to get "Please enter a username" back as an error when posting username=USERNAME&password=PASSWORD to use /api/login per https://www.newsblur.com/api#/api/login. I'm using an actual account of course. Similar, if not the same, code was working a few days back. Anyone other programmers seeing this?
Photo of SteveS

Steve

  • 4 Posts
  • 0 Reply Likes
  • confused.

Posted 2 years ago

  • 1
Photo of Samuel Clay

Samuel Clay, Official Rep

  • 5250 Posts
  • 1171 Reply Likes
I upgraded to the latest Django, which changed some things. However, I checked and it should be working fine. Are you making a POST request? It would tell you if you weren't, but I'm not sure what's going on then.
Photo of SteveS

Steve

  • 4 Posts
  • 0 Reply Likes
Thanks for the fast response Samuel. Yes, I am doing a POST request with httplib2 (python). The scrubbed data I am POSTING via httplib2 is:

urllib.urlencode({'username': 'USERNAMEHERE', 'password': 'PASSWORDHERE'})

I'm away from my personal dev machine right now but I'll take a look and triple check my script to verify and will get back with you.
Photo of SteveS

Steve

  • 4 Posts
  • 0 Reply Likes
Edit: Changed from code to pre tag

Tried it again this am and it's still giving me the username result. Here is the sample code (just in case I'm misreading something):


import httplib2
import json
import urllib

class NewsBlur(object):

def __init__(self, username, password, endpoint='https://www.newsblur.com'):
self.username = username
self.baseurl = endpoint
self.http = httplib2.Http()
creds = urllib.urlencode(
{'username': self.username, 'password': password})
print creds # To verify what is being posted
head, body = self.http.request(self.baseurl + '/api/login', 'POST', creds)
print head, body # Results

nb = NewsBlur('MYUSERNAME', 'MYPASSWORD')


The body result I see is:


{"code": -1, "authenticated": false, "errors": {"username": ["Please enter a username."]}, "result": "ok"}
Photo of Daryl Welsh

Daryl Welsh

  • 1 Post
  • 0 Reply Likes
others are impacted, like the Feed Me app on Windows Phone. I'm a user of the app, and I can't login with it to my NewsBlur account.

http://www.wpcentral.com/newsblur-alt...
Photo of SteveS

Steve

  • 4 Posts
  • 0 Reply Likes
What version of Django were you using before -- and what is in use now? Maybe I can set up a local instance and test to see if the Django upgrade caused it.
Photo of Themistoklis TzampazisTT

Themistoklis Tzampazis

  • 2 Posts
  • 0 Reply Likes
when i login with my account succesfully, response does not return me a cookie.
so any next webrequest is anonymous. can you help me please?
my csharpcode is :

RestClient client = new RestClient("http://www.newsblur.com");
RestRequest login = new RestRequest("/api/login", Method.POST);
login.AddParameter("username", "xxxxxxxxxxxxxxxxxxx");

IRestResponse response = client.Execute(login);
CookieContainer cookiecon = new CookieContainer();

if (response.StatusCode == HttpStatusCode.OK)
{
var cookie = response.Cookies.FirstOrDefault();
cookiecon.Add(new Cookie(cookie.Name, cookie.Value, cookie.Path, Cookie.Domain));
}

client.CookieContainer = cookiecon;

RestRequest feeds = new RestRequest("/reader/feeds", Method.GET);
IRestResponse response = client.Execute(login);
Photo of Samuel Clay

Samuel Clay, Official Rep

  • 5250 Posts
  • 1171 Reply Likes
The cookie's name is newsblur_sessionid. What's the response look like? It needs to say 'authenticated': true.
Photo of Themistoklis TzampazisTT

Themistoklis Tzampazis

  • 2 Posts
  • 0 Reply Likes
Sam

you wake me up and finally it was easy.

my call (added password):

RestClient client = new RestClient("http://www.newsblur.com");
RestRequest login = new RestRequest("/api/login", Method.POST);
login.AddParameter("username", "xxxxxxxxxxxxxxxx");
login.AddParameter("password", "xxxxxxxxxxxxxxxxxxx");

IRestResponse response = client.Execute(login);

response :

{"code": 1, "authenticated": true, "errors": null, "result": "ok"}

thank you!