tiktok / tiktok-opensdk-ios

The TikTok OpenSDK features Login Kit and Share Kit which allow your users to log in using their TikTok account and share content from your app to TikTok.
https://developers.tiktok.com
Other
80 stars 31 forks source link

LoginKit isWebAuth = false, but always trying web auth and fail. #28

Open levinyu-TagBy opened 7 months ago

levinyu-TagBy commented 7 months ago

Hello, I'm flutter developer, I'm using android/ios loginkit via method channel.

It's my auth code.

 let scopes: Set = [
            "user.info.basic",
            "user.info.profile",
            "user.info.stats",
            "video.list"
        ]
        self.authRequest = TikTokAuthRequest(
            scopes: scopes,
            redirectURI: redirectUri
        )
        self.authRequest?.isWebAuth = false
        self.authRequest?.send { response in

            guard let authResponse = response as? TikTokAuthResponse else {
                result(FlutterError(
                    code: "temporarily_unavailable",
                    message: "Empty Response",
                    details: nil
                ))
                return
            }
            if authResponse.errorCode == .noError {
                let resultMap: Dictionary<String,String?> = [
                    "authCode": authResponse.authCode,
                    "state": authResponse.state,
                    "grantedPermissions": authResponse.grantedPermissions?.joined(separator: ","),
                    "codeVerifier": self.authRequest?.pkce.codeVerifier
                ]

                result(resultMap)
            } else {
                result(FlutterError(
                    code: String(authResponse.error ?? "-2"),
                    message: authResponse.errorDescription,
                    details: nil
                ))
            }
        }

my info plist

...

        <string>fbshareextension</string>
        <string>tiktokopensdk</string>
        <string>tiktoksharesdk</string>
        <string>snssdk1180</string>
        <string>snssdk1233</string>
    </array>

    <key>TikTokClientKey</key>
    <string>...</string>

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>None</string>
            <key>CFBundleURLName</key>
            <string>TikTok</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>...</string>
            </array>
        </dict>

authRequest?.isWebAuth = false

  1. but, my app trying always web auth when installed tiktok app or uninstalled tiktok app.
  2. and, web auth is fail and cannot go to redirect uri.

my tiktok app status is Live, and correct input redirect uri(it's universal url). but I saw redirect fail message(formated json) on empty webpage like below:

{
    "data": {
        "captcha": "",
        "dest_url": "",
        "description": "Somwthing went wrong. Please try again",
        "error_code": 6,
    },
    "message": "error
}

I failed found that error_code 6.

what's mean to error_code 6?

how can I modify myapp for isWebAuth = false working and redirect fail resolve?

please answer me.

thanks, best regard.

aurelkpr commented 7 months ago

Did you find the solution for this @levinyu-TagBy? I have the same error with SDK 2.3.0

levinyu-TagBy commented 7 months ago

Did you find the solution for this @levinyu-TagBy? I have the same error with SDK 2.3.0

Not yet.

levinyu-TagBy commented 7 months ago

urlOpener.isTikTokInstalled() is (null).

why?

levinyu-TagBy commented 7 months ago

@aurelkpr hey, did you added CFBundleURLSchemes?

as-is

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>None</string>
            <key>CFBundleURLName</key>
            <string>TikTok</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>$my tiktok client key</string>
            </array>
        </dict>

to-be

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>None</string>
            <key>CFBundleURLName</key>
            <string>TikTok</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>$my tiktok client key</string>
                <string>www.tiktok.com</string>
                <string>snssdk1233</string>
                <string>snssdk1180</string>
            </array>
        </dict>

please try this.

I added tiktok auth domain and queries in CFBundleURLSchemes, it's work.(if tiktok app installed, tiktok app launch.)

levinyu-TagBy commented 7 months ago

and, web auth success.(tiktok app not installed),

aurelkpr commented 7 months ago

@levinyu-TagBy thanks for info. For me worked without <string>www.tiktok.com</string>.

Update. Adding snssdk1233 and snssdk1180 to CFBundleURLSchemes make the urlOpener.isTikTokInstalled() call to return true all times (even if TikTok app is not installed) :(. With them, the SDK (in case when TikTok is not installed) will redirect to the default device browser which is wrong. It should redirect to in-app browser :(. Still search for the solution ....

nickf2k commented 7 months ago

@levinyu-TagBy Did it was resolved?

sunny635533 commented 5 months ago

Did it was resolved?

levinyu-TagBy commented 5 months ago

Try this.


<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>None</string>
            <key>CFBundleURLName</key>
            <string>TikTok</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>$my tiktok client key</string>
                <string>www.tiktok.com</string>
            </array>
        </dict>
levinyu-TagBy commented 5 months ago

if you guys use to this code, sometimes uses a previously created codeVerifier rather than creating a new codeVerifier.

`CFBundleURLTypes

CFBundleTypeRole None CFBundleURLName TikTok CFBundleURLSchemes $my tiktok client key www.tiktok.com snssdk1233 snssdk1180 `