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

When some users are authorized to log in, they will jump to an external browser to open the tiktok web page, but "authRequest?.isWebAuth" is false. #27

Open
sunny635533 opened this issue Mar 28, 2024 · 0 comments

Comments

@sunny635533
Copy link

sunny635533 commented Mar 28, 2024

When some users are authorized to log in, they will jump to an external browser to open the tiktok web page, but "authRequest?.isWebAuth" is false.

my tiktok sdk version is 2.2.0,

pod 'TikTokOpenSDKCore'
 pod 'TikTokOpenAuthSDK'

my code :

@objc
  public static func getAuthCode(scopes: NSString,resolver:@escaping RCTPromiseResolveBlock,rejecter:@escaping RCTPromiseRejectBlock)->Void{
    resolve = resolver;
    reject = rejecter;
    
    let scopesArray:Array = scopes.components(separatedBy: ",");
    var setScopes: Set<String> = [];
    let redirectUri = "https://m.iboominggxxx.xx/"
    let dict = NSMutableDictionary();
    var authRequest: TikTokAuthRequest?

    for index in 0 ..< scopesArray.count {
      setScopes.insert(scopesArray[index])
    }
    print("===getAuthCode 1111111==== ",setScopes);
    
    authRequest = TikTokAuthRequest(scopes: setScopes, redirectURI:redirectUri)
    authRequest?.isWebAuth = false
    
    DispatchQueue.main.sync {
      authRequest?.send { response in
        guard  let myresponse = response as? TikTokAuthResponse else {
          let errorObj = NSError(domain: "getAuthCode fail", code: -1);
          authRequest = nil
          reject?("getAuthCode fail","myresponse is null!",errorObj);
          return }

        if myresponse.errorCode != .noError {
          let message = "Error: \(myresponse.error ?? ""),code:\(String(myresponse.errorCode.rawValue)), Error Description: \(myresponse.errorDescription ?? "")"
          let errorObj = NSError(domain: message, code: myresponse.errorCode.rawValue);
            reject?("getAuthCode fail","errorCode is error! ",errorObj);
        }else{
          dict.setValue(myresponse.errorCode.rawValue, forKey:"errorCode")
          dict.setValue(myresponse.errorDescription, forKey:"errorMsg")
          dict.setValue(myresponse.authCode, forKey:"authCode")
          dict.setValue(scopes, forKey:"grantedPermissions")
          dict.setValue(authRequest?.pkce.codeVerifier, forKey:"codeVerifier")
          dict.setValue(redirectUri, forKey:"redirectUri")
          resolve?(dict)
          authRequest = nil
        }
        print("===getAuthCode 33333==== ", dict);
      }
    }
  }

//============= AppDelegate.m ===============
- (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
  
  if([TTKSDKURLHandler handleOpenURL:url]){
    return true;
  }
  
    return [RCTLinkingManager application:application openURL:url options:options];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
  
  if([TTKSDKURLHandler handleOpenURL:url]){
    return true;
  }
  
    return [RCTLinkingManager application:application openURL:url
                                 sourceApplication:sourceApplication annotation:annotation];
}

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{

  if([TTKSDKURLHandler handleOpenURL:url]){
    return true;
  }
  
  return NO;
}

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray * __nullable restorableObjects))restorationHandler{

   BOOL result = [TTKSDKURLHandler handleOpenURL:userActivity.webpageURL];
   NSLog(@"=========== restorationHandler  ========%@  result=%d",userActivity.webpageURL,result);
   if(result){
      return true;
   }

  return false;
}

isWebAuth is false, so user only open tiktok app to authorize.

So it is very strange why the user can jump to an external browser and open the tiktok authorization login on the webpage.
This is video record.

Lark20240328-163421.mp4

Hope help, thank you!

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

1 participant