3

I'm developing an Android app using Gigya to allow people to register using Facebook and Twitter; in parallel another developer is doing the same thing in iOS. We want to implement custom login UI.

The standard method uses Gigya's own UI and is documented here:

http://developers.gigya.com/035_Mobile_SDKs/020_Android#Logging_in_the_User

Beneath, it simply suggests:

If you wish to implement the graphic design by yourself, use the login method instead.

The standard login method calls a dedicated post-login callback with an onLogin(...) method and all subsequent flows are described as stemming from this event. The other login method calls a standard onGSResponse(...) callback; it's not clear how the response can be used to construct a user so I've set up my implementation to call socialize.getUserInfo. Attempts to call either method have resulted in lots of unusual errors.

As per the Gigya instructions I'm starting up with

mGSAPI = new GSAPI(GIGYA_APP_KEY, this);
mGSAPI.setAPIDomain("eu1.gigya.com");

in onCreate(...) (where GIGYA_APP_KEY is a value copied from our console). I'm calling setAPIDomain because we were getting an invalid data center error (albeit with a 500001 code, not a 301001 code!), which this has fixed.

Facebook login goes through the login flow as I'd expect and then comes back with error 400093 (which the docs tell me is an invalid API parameter, and has the message " Missing parameter: client_id").

Twitter login comes back with 206002, " Account Pending Verification", which seems to make sense; I then call

mGSAPI.sendRequest(
        "getUserInfo",
        null, //parameters
        true, //use HTTPS
        this, //the callback
        null //a context object
);

and this gives me the error:

Missing required parameter: No secret or signature were provided. Request could not be verified.

The documentation for socialize.getUserInfo suggest a UID is required for web apps, but not for native ones. It mentions no other mandatory fields. I am a bit stuck ... shouldn't the GSAPI object be handling verification, as it's initialized with the API key?

Andrew Wyld
  • 7,133
  • 7
  • 54
  • 96

1 Answers1

1

I can give you some direction at a very high level for integrating GIGYA. (Code below is not verbatim) Hopefully it is somewhat helpful.

For a private Android app I had created a Manager object (GigyaManager) that maintained a singleton instance of the GSAPI object.

This singleton GigyaManager was initialized in my application object:

public static GigyaManager getInstance(String apiKey, Context context) {
    mGSAPI = new GSAPI(apiKey, context);
}

My GigyaManager class also had a wrapper method for handling the login w/social services:

public void loginWithSocialService(GigyaSocialProvider provider, GSResponseListener listener) throws Exception {
        // did the user attempt a social login, and bail out on the registration
        // phase?
        if (GigyaManager.getInstance().getGSAPI().getSession() != null) { 
            logout();
        }


        GSObject providerArgs = new GSObject();
        providerArgs.put(GigyaManager.GIGYA_ARG_PROVIDER, provider.name().toLowerCase());

        mGSAPI.login(providerArgs, listener, null);
    }

This was fired from an onClick listener in a fragment that contained a "login" button:

GigyaManager.getInstance("appKey", getActivity()).loginWithSocialService(GigyaSocialProvider.FACEBOOK, this);

That fragment had to implement GSResponseListener that has the callbacks to deal with whether the login was successful or not:

@Override
public void onGSResponse(String method, GSResponse response, Object context) {
    if (!method.equalsIgnoreCase("login") || response.getErrorCode() != 0) {
        return;
    }
    GIGYAResponseWrapper resp = new GIGYAResponseWrapper(response.getResponseText());

    // user is attached to login provider? 
    if (resp.isIsAttached()) {
        // start some sort of loader or asynctask to get information about user account
        // connected to GIGYA social login

        Bundle args = new Bundle();
        args.putString(ARG_UID, resp.getUid());
        args.putString(ARG_UID_SIGNATURE, resp.getUidSignature());
        args.putString(ARG_SIGNATURE_TIMESTAMP, resp.getSignatureTimestamp());
        args.putString(ARG_SOCIAL_NICKNAME, resp.getNickname());

    } else {
        // login success, but this social account is not associated with anything in GIGYA
    }
}
NPike
  • 13,136
  • 12
  • 63
  • 80
  • Hi, thanks—this is pretty helpful, but it's unfortunately quite close to what I have already. As I understand it the 400093 error I'm getting from Facebook is caused by using Single Sign On, but I have the Facebook app set up as though for SSO and also my login code contains `GSObject params = new GSObject(); params.put(GIGYA_PROVIDER, mProvider); if(mProvider.equals("facebook")) { params.put("facebookAppId", "APPID HERE"); } mGSAPI.login( params, mResponseListener, null);` – Andrew Wyld Apr 23 '13 at 11:15