0

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.

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}

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.

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.