pushbullet - 401 Status Returned on Access Token Errors -


while 401 unauthorized may seem spiffy these ("access token missing or invalid") can throw many client http stack prompting user credentials, won't succeed anyway since normal http authentication mechanisms not in play.

while can detour using client library can direct not attempt auto-auth or user prompting (and have done so) seems violate rfc 7235 far can tell.

i suspect 403 forbidden more compliant here , less grief api users. of them see non-2xx status , run json "error" reponse body.

i have detour i'm not complaining, seems fishy here. surely i'm missing something? common practice use 401 in manner rest-like http apis?

more detail

this works long proper auth token used, causes gui prompt user/pw if bad token used:

set jsonbag = pbconfig.cloneitem("createpushjson") 'make deep copy of template json. jsonbag     .item("title") = txttitle.text     .item("body") = txtbody.text end  xmlhttp     .abort 'clean failed request if any.     .open "post", pbconfig.item("createpushurl"), true     .setrequestheader "access-token", pbconfig.item("accesstoken")     .setrequestheader "content-type", "application/json"     .onreadystatechange = sinkrschange     .send jsonbag.json end 

if prompt canceled user 401 gets reported code.

in light of information below tried sending auth token user id value. raises prompt if auth token correct:

set jsonbag = pbconfig.cloneitem("createpushjson") 'make deep copy of template json. jsonbag     .item("title") = txttitle.text     .item("body") = txtbody.text end  xmlhttp     .abort 'clean failed request if any.     .open "post", pbconfig.item("createpushurl"), true, pbconfig.item("accesstoken")     .setrequestheader "content-type", "application/json"     .onreadystatechange = sinkrschange     .send jsonbag.json end 

if user manually enters valid auth token prompt user id request succeeds.

based on new information below

this can made work explictly sending "." password:

set jsonbag = pbconfig.cloneitem("createpushjson") 'make deep copy of template json. jsonbag     .item("title") = txttitle.text     .item("body") = txtbody.text end  xmlhttp     .abort 'clean failed request if any.     .open "post", pbconfig.item("createpushurl"), true, pbconfig.item("accesstoken"), "."     .setrequestheader "content-type", "application/json"     .onreadystatechange = sinkrschange     .send jsonbag.json end 

correct token value works, bad token value returns 401 can handled. no credentials prompt dialogs now.

normal http authentication mechanisms technically in play. api asks browser credentials can requests in browser (someone requested that).

http libraries have special behavior 401s seem problem, 1 time happened been able disable magic 401 handling. have no idea in violation of rfc 7235 here. rfc 2616 10.4.2 seems indicate current behavior "correct". have list of http clients prompt user credentials?

maybe 403 makes more sense here, stripe @ least seems use 401: https://stripe.com/docs/api#errors , rest. switching 403 break existing clients well. clients don't @ json body oddly enough, @ status code.

i think if make http api have 200/400/500 status codes post of json encoded bodies , json responses.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -