question

wollzeit avatar image
0 Likes"
wollzeit asked

Problem with CORS policy when accessing token API

Hello all together, I try to get through the ebay Auth application grant flow, but I have a problem, because I can't read the response ebay gives me. The problem relates in CORS policy problems and the exact message says: **Access to XMLHttpRequest at ' https://api.ebay.com/identity/v1/oauth2/token' from origin ' https://example.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.** I don't know where the problem relates in, so here is the way I try to access this API. 1. I redirect the user from my applciation to this ebay endpoint to retrieve the accesstoken: https://auth.ebay.com/oauth2/authorize?client_id=${clientId}&redirect_uri=${this.redirect_uri}&response_type=code&scope=${scope} 2. When redirected back after accepting the permissions my application needs to use the appropriate ressources, I extract the responed accesstoken from the URL and encode it. 3. Right after that I want to exchange these accesstoken to a usertoken by making a call to this endpoint: const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': 'Basic ' + btoa(this.clientId) + ':' + btoa(this.clientSecret) }) }; const data = { 'grant_type': 'authorization_code', 'code': accessToken, 'redirect_uri': this.redirect_uri }; this.httpClient.post(' https://api.ebay.com/identity/v1/oauth2/token', data, httpOptions).subscribe( data => console.log(data), error => console.log(error) ) So when starting this process I always get the message back saying that the response has been blocked. Does anyone know where my problem relates in and can help me? Many thanks in advice!
cors
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.