简体   繁体   中英

Implementing Azure Mobile App Auth (with Twitter) on an iOS Client Using Swift 2 with WindowsAzureMobileService.framework (Client Side Mode)

I'm trying to implement an Azure mobile app and am working on the iOS client in Swift 2.

I have Twitter configured as an identity provider via the Azure portal and I'm trying to get my iOS app to be authorised/authenticated using a client side token and the WindowsAzureMobileService framework; ie I've used TwitterKit on the iOS Client and have authenticated directly with Twitter an now want to use the token from that to present to the Azure gateway. The code below (or something like it with my actually Azure URL references) compiles and runs fine:

if let sessionToken = Twitter.sharedInstance().sessionStore.session()?.authToken {
            let token = ["authenticationToken" : sessionToken]
            let msClient = MSClient(applicationURLString: "https://someapp.azurewebsites.net", gatewayURLString: "https://somegateway.azurewebsites.net", applicationKey: "")
            msClient.loginWithProvider("twitter", token: token, completion: { (user: MSUser?, error: NSError?) -> Void in
                print("User: \(user)")
                print("Error: \(error?.userInfo)")
            })
        }

But an error (error: NSError?) is returned as follows

Error: Optional([NSLocalizedDescription: The server returned an error.])

So my question is how do I go about diagnosing this? Is there anything I can get/setup in the Azure Portal or anywhere else. Also is there anything obvious that I'm doing wrong? (I'm unsure that I have the token directionary setup right for example).

This doc on SSO with AAD directs you to use access_token as the key for the token.

Could you try changing to use this code?

let token = ["access_token" : sessionToken]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM