Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49082

Sketchfab CORS error

$
0
0

Hi,
in a Ionic app we would like to permit the user to upload 3D models on Sketchfab.
We implemented the Oauth2 login as described in Schetchfab Oauth2 guide about the grant type Authorization Code.

We take the AUTHORIZATION_CODE with the link and then we try to retrieve the token with this method:

getSkToken(skData): Observable {
let headers = new HttpHeaders({
‘content-type’: ‘application/x-www-form-urlencoded’
});

const options = { headers };
const serviceName = ‘https://sketchfab.com/oauth2/token/’;

return from(this.http.post(serviceName, skData, options).pipe(
map(data => {
return data;
},
error => {
console.log(error);
})
));
}

where skData are the correct values requested:

-‘grant_type’: ‘authorization_code’ -'code': [AUTHORIZATION_CODE]
-‘client_id’: [CLIENT_ID] -'client_secret': [CLIENT_SECRET]
-‘redirect_uri’: [REDIRECT_URI]`

We have this CORS error:

Access to XMLHttpRequest at ‘https://sketchfab.com/oauth2/token/’ from origin ‘https://localhost:4200’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

We tried to change the POST header in many ways, like:

let headers = new HttpHeaders({
‘content-type’: ‘application/x-www-form-urlencoded’,
‘Access-Control-Allow-Headers’: ‘Content-Type’,
‘Access-Control-Allow-Methods’: ‘POST’,
‘Access-Control-Allow-Origin’: ‘*’
});

But always CORS error, but in preflight.

Some idea?

Thank you!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49082

Trending Articles



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