Client-side authentication with google+ for iOS on azure mobile service backend
Asked Answered
G

0

9

I'm trying to integrate server-side side Google+ sign-in into my iOS app.

This is what i did:

func application(application: UIApplication, openURL url: NSURL, sourceApplication: NSString?, annotation: AnyObject) -> Bool
{
   return GPPURLHandler.handleURL(url, sourceApplication: sourceApplication, annotation:annotation)
}

// In the view controller @IBOutlet weak var gpLoginView: GPPSignInButton!

    googlePlus = GPPSignIn.sharedInstance()
    googlePlus.shouldFetchGooglePlusUser = true
    googlePlus.clientID = "CLIENT-ID"
    googlePlus.homeServerClientID = "HOME-CLIENT-ID"
    googlePlus.scopes.append(kGTLAuthScopePlusLogin)
    googlePlus.delegate = self;


func finishedWithAuth(auth: GTMOAuth2Authentication!, error: NSError!)
{
    if error != nil
    {
        println("[GoogleAuthentication] Error: \(error)")
    }
    else
    {
        var serverCode = GPPSignIn.sharedInstance().homeServerAuthorizationCode
        if serverCode == nil
        {
            println("[GoogleAuthentication] homeServerAuthorizationCode is missing")
            googlePlus.disconnect()
        }
        else
        {
            client.loginWithProvider("google", token: ["access_token" : serverCode])
            {
                user, error in
                println("[Azure::loginWithToken] Result. User=\(user). Error=\(error).")
            }
        }
    }
}

My have two credentials in my google developer console. One for iOS application and another for web application. The ClientID from iOS application is specified in googlePlus.ClientID. The ClientID from web application is specified in homeServerClientID. Also, the same ClientID and Secret is specified in Azure Mobile Service Identities configuration.

Also the URL Schema is created with the name of my application bundle.

I get the client portion of the authentication passed successfully and was able to get the homeServerAuthorizationCode, but when i try to do the server side portion i get an error from azure mobile service. The error i get is: Error Domain=com.Microsoft.WindowsAzureMobileServices.ErrorDomain Code=-1301 "The server returned an error." UserInfo=0x170464c80 {NSLocalizedDescription=The server returned an error.}.

Please help to figure out what am I doing wrong?

Thanks, Ruben

Gerdes answered 21/3, 2015 at 8:4 Comment(3)
I am also facing this issue now, @Gerdes did you find out solution for this.Doucette
have anyone solve this, cos i am still facing the issueLundin
sorry guys, no solution. I eventually walked away from Azure and things just worked with GoogleSDK alone.Gerdes

© 2022 - 2024 — McMap. All rights reserved.