*grant_type=password.*


For your convenience, I  am providing the Angular JS relevant code


*// from Angular Controller js*

var dataObj="
grant_type=password&username=xxxxxxxxx&password=xxxxxxxxx&scope=openid";

                         Service.callTokenAPI(dataObj)
.then(function onSuccess(response) {
console.log("Success");
console.log("result #### = " + JSON.stringify(response));
}, function onFailure(error) {
console.log("failure");
});



*//from Service.js*

var callTokenAPI = function (dataObj) {
console.log("Call server dataObj =" + angular.toJson(dataObj));
var secret=clientKey+":"+clientPass;
var base64Encoded= btoa(secret);
console.log("base64Encoded="+base64Encoded);
return $http({
url: tokenAPI,
method: 'POST',
data: dataObj,
headers: { "Content-Type": "application/json;charset=utf-8"
,"Authorization":base64Encoded}
});
};


When I  run this I am getting CORS error screenshot shared earlier.

Regards
Shib


On Thu, Jun 14, 2018 at 3:00 PM, Rushmin Fernando <rush...@wso2.com> wrote:

> Could you please let us know the grant type you are using here. I would
> like to know whether this is a valid use case.
>
> On Thu, Jun 14, 2018 at 2:54 PM shibsankar <src...@gmail.com> wrote:
>
>> Yes.  I get  same CORS error with the correct endpoint, which is */*
>> *token*
>>
>> screenshot attached.
>>
>> Regards
>> Shib
>>
>> On Thu, Jun 14, 2018 at 2:42 PM, Rushmin Fernando <rush...@wso2.com>
>> wrote:
>>
>>> In the console logs, it says */toekn, *which is wrong spellings.
>>>
>>> Do you get the same CORS error with the correct endpoint, which is */**token
>>> *?
>>>
>>> On Thu, Jun 14, 2018 at 2:26 PM shibsankar <src...@gmail.com> wrote:
>>>
>>>> I am receiving CORS Error when I call the WSO2 token API  from Angular
>>>> JS application.
>>>>
>>>> How do you fix this?
>>>>
>>>> Regards
>>>> Shib(9831418066)
>>>>
>>>>
>>>> _______________________________________________
>>>> Dev mailing list
>>>> Dev@wso2.org
>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>
>>>
>>>
>>> --
>>> *Best Regards*
>>>
>>> *Rushmin Fernando*
>>> *Technical Lead*
>>>
>>> WSO2 Inc. <http://wso2.com/> - Lean . Enterprise . Middleware
>>>
>>> mobile : +94775615183
>>>
>>>
>>>
>>
>
> --
> *Best Regards*
>
> *Rushmin Fernando*
> *Technical Lead*
>
> WSO2 Inc. <http://wso2.com/> - Lean . Enterprise . Middleware
>
> mobile : +94775615183
>
>
>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to