Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
levinyu-TagBy opened this issue Mar 29, 2024 · 10 comments
Open

Comments

@levinyu-TagBy
Copy link

levinyu-TagBy commented Mar 29, 2024

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
Copy link

aurelkpr commented Apr 3, 2024

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

@levinyu-TagBy
Copy link
Author

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

Not yet.

@levinyu-TagBy
Copy link
Author

urlOpener.isTikTokInstalled() is (null).

why?

@levinyu-TagBy
Copy link
Author

@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
Copy link
Author

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

@aurelkpr
Copy link

aurelkpr commented Apr 9, 2024

@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
Copy link

nickf2k commented Apr 18, 2024

@levinyu-TagBy Did it was resolved?

@sunny635533
Copy link

Did it was resolved?

@levinyu-TagBy
Copy link
Author

levinyu-TagBy commented Jun 14, 2024

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
Copy link
Author

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

<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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants