Thanks Tarun for the reply.
I however was able to resolve the issue completely using the code below. I paste it in the hopes that it could help someone one day.
(it took me 6 days of searching everything about Oauth along with trying all the libraries & examples i could find...scribe,signpost etc. but SocialAuth was the best and most straight forward to use. A big UP to Tarun and the team that created this fantastic Library)
//so heres the code.
// I have an activity which has a layout with 2 imagevies. One for facebook and other for googleplus. On the onclick even I call this code below and pass a parameter denoting which one was clicked.
private void runSocialOauthStuff(String strProvider) {
AdapterSocialAuth = new SocialAuthAdapter(new ResponseListener()); //create a new instance of the adapter. I've already initialized it in code above so at this point I'm just creating an instance
try {
if(strProvider.contains("google")) {
AdapterSocialAuth.addConfig(SocialAuthAdapter.Provider.GOOGLEPLUS,
"xxxxxx", // client secret here
AdapterSocialAuth.authorize(Activity_SignUp.this, SocialAuthAdapter.Provider.GOOGLEPLUS); //this step does the work and calls the webview for users to log in. the response is sent to the response listener shown below
} else { //here i have also some code for facebook.
if(strProvider.contains("facebook")) {
AdapterSocialAuth.addConfig(SocialAuthAdapter.Provider.FACEBOOK,
"xxxxxxxxxx", //client key
"xxxxxxxxxxxxxxxxxxxx", //client secret
"email"); //permissions
AdapterSocialAuth.authorize(Activity_SignUp.this, SocialAuthAdapter.Provider.FACEBOOK);
};
}
} catch (Exception e) {
Toast.makeText(Activity_SignUp.this,"Error Occured " + e.getMessage(),Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
//the response listener gets the results from the above code. Mine is simple because I'm only interested in email. You could get any of the other profile details that user has authorized.
private final class ResponseListener implements DialogListener {
@Override
public void onComplete(Bundle values) {
String strUserEmail;
Profile profileMap = AdapterSocialAuth.getUserProfile();
strUserEmail=profileMap.getEmail();
if(strUserEmail!=null && strUserEmail.trim().length()>0){
db = DatabaseRoutines.getInstance(Activity_SignUp.this); // I initialize my database instance
db.setUserEmail(strUserEmail); // here i save to the db.
Toast.makeText(Activity_SignUp.this,"The Email " + strUserEmail + " Saved Successfully.",Toast.LENGTH_LONG).show(); // message to the user showing the actual email saved
GotoMainPage(); // this closes the current activity using "finish()" and opens the main activity.
} else {
Toast.makeText(Activity_SignUp.this,"Email Address could not be acquired. Please try again.",Toast.LENGTH_LONG).show();
}
}