sumup / sumup-ios-sdk

Other
46 stars 25 forks source link

Impossible to set up any more on iOS #123

Closed raphaels17 closed 1 year ago

raphaels17 commented 1 year ago

The developer form for integration is simply broken. One can no longer "Create client credentials" for Application Type "iOS" or other, other types work.

The save button keeps failing image

I have tried on several account and browser

This is the data used if this can help

{
    "message": "Request failed with status code 401",
    "name": "AxiosError",
    "config": {
        "transitional": {
            "silentJSONParsing": true,
            "forcedJSONParsing": true,
            "clarifyTimeoutError": false
        },
        "transformRequest": [
            null
        ],
        "transformResponse": [
            null
        ],
        "timeout": 0,
        "xsrfCookieName": "XSRF-TOKEN",
        "xsrfHeaderName": "X-XSRF-TOKEN",
        "maxContentLength": -1,
        "maxBodyLength": -1,
        "env": {
            "FormData": null
        },
        "headers": {
            "Accept": "application/json, text/plain, */*",
            "Content-Type": "application/json",
            "Authorization": "Bearer xxxx"
        },
        "baseURL": "https://auth.sumup.com/api/v1",
        "method": "post",
        "url": "/compat/client-projects/CPZYNVG9/credentials",
        "data": "{\"application_type\":\"ios\",\"client_name\":\"HangersPro\",\"redirect_uris\":[\"https://hangers.io/\"],\"cors_uris\":[]}"
    },
    "code": "ERR_BAD_REQUEST",
    "status": 401
}
jadeburton-sumup commented 1 year ago

We believe this issue is fixed, please reach out to me if you continue to have problems

raphaels17 commented 1 year ago

Hi

This works though.. I am suprise I can only enter "URL" and not sheme with myappname:// ? Am i missing something ?

tatianalizarazo commented 1 year ago

Hey Raphael,

The issue has been fixed, and now you can enter a custom schema in the URL.

Kind regards,

SumUp

raphaels17 commented 1 year ago

Hi thanks, I have been able to change. This being said, It somehow still doesn't work.. For what it's worth ChatGPT 4 doesn't seem to find anything wrong with my code either..I am afraid the issue is still not on my hand. The project is the SumUpSDKSampleApp , where I try to implement SumUpSDK.login(withToken: token.

I have attached the project. Can you help ?

When calling : // Start the authentication session session = ASWebAuthenticationSession(url: request.url!, callbackURLScheme: encodedURI) And clicking OK I get unknow error.

here is the entire function . I will offcourse use another account for production of our PoS app.

private func requestAuthorizationCode() {
        // Set up the authorization request

// let authURLString = "https://api.sumup.com/authorize?response_type=code&client_id=cc_classic_1G6T7smTwnawrORglMA903dJJYpG6&redirect_uri=https://www.hangers.io/sumup&scope=payments.history payments.app-settings payments.profile_readonly".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! // let authURL = URL(string: authURLString)! let authURL = URL(string: "https://api.sumup.com/authorize")! let redirectURI = "com.sumup.sdk.sample.swift://authsum" let encodedURI = redirectURI.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)! var components = URLComponents(url: authURL, resolvingAgainstBaseURL: false)! components.queryItems = [ URLQueryItem(name: "response_type", value: "code"), URLQueryItem(name: "client_id", value: "cc_classic_2CgPnRf5uKic33Ovgkr1IMnThAH5S"), URLQueryItem(name: "redirect_uri", value: encodedURI), URLQueryItem(name: "scope", value: "payments.app-settings payments.profile_readonly".addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)!), ] let url = components.url! let request = URLRequest(url: url)

        // Start the authentication session
        session = ASWebAuthenticationSession(url: request.url!, callbackURLScheme: encodedURI) { [weak self] callbackURL, error in
            guard let self = self else { return }

            // Handle the callback URL to retrieve the authorization code
            guard let code = self.extractAuthorizationCode(from: callbackURL) else {
                print("Failed to retrieve authorization code: \(error?.localizedDescription ?? "Unknown error")")
                return
            }

            // Exchange the authorization code for an access token
            OAuthSumUpAccountManager.getSumUpToken(code: code,completion: { (token, error) in

                SumUpSDK.login(withToken: token!) { [weak self] (success: Bool, error: Error?) in

                    //debugPrint("SUMUP logged in :  \(SumupSDK.isLoggedIn())")
                    guard error == nil else {

// self?.showResult(title:.sumUpError,string: .sumUpNotLoggedIn, isError: true)

                        //debugPrint("SUMUP error after calling oAuth url :  \(error.debugDescription)")
                        // errors are handled within the SDK, there should be no need
                        // for your app to display any error message
                        return
                    }
                }
            })

        }

    if #available(iOS 13.0, *) {
        session?.presentationContextProvider = self
    } else {
        // Fallback on earlier versions
    }
        session?.start()
    }

SampleApp.zip