Problem getting products through sylius API using iOS

Currently I’m trying to consume sylius api using the domain, I’ve authenticated properly and got an access token with no problem but when it comes to passing the access token to the authorization header I ran into a problem with response { error = "access_denied"; "error_description" = "OAuth2 authentication required"; } although the api works fine through postman , here’s my sample code

func getTotalProducts(page:String, completionHandler: @escaping (_ totalProducts: TotalProducts) -> Void){
    let urlPath=APIManager.baseURL+"api/v2/products"
    let headers = ["Content-Type":"application/json","Authorization":"Bearer \(token)","X-Authorization":"Bearer SampleToken","Auth":"Bearer SampleToken","auth":"Bearer SampleToken"]
    var request = URLRequest(url:  NSURL(string: urlPath)! as URL)
    // Your request method type Get or post etc according to your requirement
    request.httpMethod = "GET"
    request.setValue("Bearer SampleToken", forHTTPHeaderField: "Authorization")
    request.setValue("application/json", forHTTPHeaderField: "Content-Type")
    request.setValue("Bearer SampleToken", forHTTPHeaderField: "X-Authorization")
    request.setValue("Bearer SampleToken", forHTTPHeaderField: "auth")
        .responseJSON { response in
            case .success(let value):
                let totalProducts = Mapper<TotalProducts>().map(JSON: value as! [String : Any])!
            case .failure(let error):
                print("something went wrong \(error.localizedDescription)")

I remember an issue where it was the server (Apache) stripping the headers needed for authentication. Are you able to see the request in Symfony Profiler? I’d check if it contains the desired headers.

EDIT: I did not notice you are using :slight_smile: Can you try it with local Sylius installation and see if it is any different?

I will try to see symphony profiler to see the results, but if so why the request succeeds through postman?

I use the good system and In this, I use the IOS device which is really important for us. And I use the good type of information and if I have an issue then go to the technical support to solve the problem. you can also go to the laptop repair dubai to solve the problem. which is very useful for us.

if you faced any problems with your laptops, You can connect with scorpionfix, one of the best laptop service center in Sharjah to solve the problems. They are very experienced professionals.