I am trying ot call set password api, but getting error as [[ Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.]]
I have set origin on okta. but still getting this error. Could you please confirm what exactly causing this issue. I am using oauth 2 and it is working fine when i am trying ot login or create user using api. is there any roles required to set password using api or any other issue??
Please advise…
vijet
May 29, 2018, 4:15am
2
Hi @ankushbanduni
Have you tried using the postman collections?
Can you post the code and the exact API you’re trying to call?
Please find the below code snippet. I have edit authorization key below for security reason. coudl you please advise:-
const httpOpt = {
headers: new HttpHeaders({
‘Access-Control-Allow-Methods’: ‘GET,POST’,
‘Accept’: ‘application/json’,
‘Cache-Control’: ‘no-cache’,
‘Content-Type’: ‘application/json’,
‘Authorization’: 'SSWS ’ + ‘0089mrDTm4_S4XifO5NQm’
})
};
resetPassword(form){
const body = {
'credentials': {
'password' : { 'value': form['password'],
}
,
}
}
console.log(body);
this.http.post(‘https://dev-123456-admin.oktapreview.com/api/v1/users/00uefjlm2hVE0UpS60h7 ’, body, httpOpt)
.subscribe(res => {
console.log(“successful”);
},
err => {
console.log(err);
});
}
vijet
May 29, 2018, 5:14am
4
I think the issue is this
Change it to https://dev-123456.oktapreview.com
and you should be good to go.
Let me know if that works.
i have tried it tooo. but no luck…
vijet
May 29, 2018, 5:20am
6
Ah… I tried with and without admin
and it works fine for me.
I’m using the postman collections reference here - https://developer.okta.com/docs/api/getting_started/api_test_client#collections-quick-reference
Import the users collection from above and check if that works.
Try generating a new API key and use that in postman.
the strange thing is it is working fine on postman. but not in my angular app. is it something related to roles or something else?
@vijet : Does it need any sessiontoken?
vijet
May 29, 2018, 2:31pm
9
@ankushbanduni - You don’t need a sessionToken for this operation. You only need an API token.