Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

Individual accounts error unsupported_grant_type

$
0
0

I am starting a project where I want a phone app to read from a webapi.

I am not sure about authentication but looked at the Individual accounts example here http://www.asp.net/web-api/overview/security/individual-accounts-in-web-api 

I am not even sure if this is the authentication model I should use.

I can get this working in fiddler, but when I try to duplicate in javascript I get the {"error":"unsupported_grant_type"} error

$.ajax({
        url: encodeURI('/Token'),
        type: 'POST',
        data: "grant_type=password&username=xxxxx@xxxxxx.com.au&password=xxxxxxx",
        contentType: 'application/x-www-form-urlencoded',
        success: function (data) {
            alert(data.access_token)$.ajax({
                url: encodeURI('/Token'),
                type: 'GET',
                beforeSend: function (xhr) {
                    xhr.setRequestHeader('Authorization', 'Bearer ' + data.access_token);
                },
                success: function (data) {
                    alert()
                },
                contentType: 'application/json',
                error: function () { },
            });
        },
        error: function () { },
    });

What am I doing wrong?
Thanks


Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>