小编man*_*rio的帖子

带有重定向URI 的 Swift OAuth2.0

我正在使用提供 OAuth2.0 身份验证的服务。这是我需要的步骤:

  • 打开以用户 ID 作为参数的 URL
  • 用户批准我的应用程序(已注册)。
  • 用户被重定向到 RedirectUri,访问令牌位于哈希中。

第三点是我的主要问题。

我已经使用微软库实现了 OAuth,一切正常。但我不能在这里使用它们,所以我正在尝试https://github.com/OAuthSwift/OAuthSwift这个。

这是我的代码:

private func authenticationService() {
    // create an instance and retain it
    let oauthswift = OAuth2Swift(
        consumerKey:    "xx",
        consumerSecret: "xxx",
        authorizeUrl:   "//myurl + userId",
        responseType:   "token"
    )

    oauthswift.authorizeURLHandler = OAuthSwiftOpenURLExternally.sharedInstance

    let handle = oauthswift.authorize(
        withCallbackURL: "???",
        scope: "", state:"") { result in
        switch result {
        case .success(let (credential, response, parameters)):
          print(credential.oauthToken)
          // Do your request
        case .failure(let error):
          print(error.localizedDescription)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这可以正确打开我的 Safari,但随后我被重定向到哈希中包含访问令牌的 URI,但什么也没发生。 …

oauth token ios swift swiftui

5
推荐指数
1
解决办法
3816
查看次数

在 RealityKit 中启用手势

我有一个自定义的 usdz 文件(不是通过代码创建的,但比方说一把真正的椅子!)。我将其保存在Entity.

一旦我有了它,这就是我的代码:

func updateUIView(_ uiView: ARView, context: Context) {
            
    if let modelEntity = model.modelEntity {
        
        print("\(model.modelName)")
        
        let anchorEntity = AnchorEntity(plane: .horizontal)
        
        anchorEntity.addChild(modelEntity.clone(recursive: true))
        
        uiView.scene.addAnchor(anchorEntity)
        
        // modelEntity.generateCollisionShapes(recursive: true) 
        // If we have multiple object, recursive true help to generate collision for all of them
        
        uiView.installGestures(.rotation, for: modelEntity as! Entity & HasCollision)
        
        uiView.debugOptions = .showPhysics
        
    } else {
        
        print("Unable to load modelEntity for \(model.modelName)")
        
    }
}
Run Code Online (Sandbox Code Playgroud)

这里的问题是“参数类型‘Entity’不符合预期类型‘HasCollision’”。所以我无法添加任何手势。

但我找不到任何有用的资源来实现我的最终目标。有什么建议吗?

augmented-reality swift arkit swiftui realitykit

2
推荐指数
1
解决办法
3958
查看次数

标签 统计

swift ×2

swiftui ×2

arkit ×1

augmented-reality ×1

ios ×1

oauth ×1

realitykit ×1

token ×1