Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

trying to get a oauth token using fiddler

I've been following Scott Allen's ASP.NET MVC 5 Fundamentals on pluralsight, and can successfully request a token, using a simple HTML page, but now need to try and do this using fiddler. the reason I need to test it using fiddler, is that this is in essence the way my apu will be called. An ios device app is being written, and i have to do the api piece.

So, i enter the followdin in fiddler:

HEADER:

 POST http://localhost:53140/token HTTP/1.1
    Content-Type: application/json
    Host: localhost:53140
    Content-Length: 50

BODY: grant_type=password:

{"userName":"something",
"password":"password"}

and I get a 400 - bad request.

i've changed the content type to : application/x-www-form-urlencoded but still a 400.

what am i doing wrong?

EDIT

Even tried "username=username&password=password" still no joy

EDIT

Whoops, had the grant_type in the wrong place. this needed to be in the body:

grant_type:password&username:username&password:password

Now i get username or password are not valid:

{"error":"invalid_grant","error_description":"The user name or password is incorrect."}

i'll leave the post active, as this may be a red herring.

like image 819
CSharpNewBee Avatar asked Nov 30 '22 01:11

CSharpNewBee


1 Answers

In fiddler, make sure after grant_type=password&username=username&password=password there is no space or line break.

like image 125
sunil Avatar answered Dec 10 '22 18:12

sunil