I am building an android app that connects to facebook, twitter and google for user logins. I am getting the following error -
org.brickred.socialauth.exception.SocialAuthException: Unable to retrieve the access token. Status: 400. Could not connect using SocialAuth
The code is as follows -
package com.opaxlabs.boatbrat;
import org.brickred.socialauth.Profile;
import org.brickred.socialauth.android.DialogListener;
import org.brickred.socialauth.android.SocialAuthAdapter;
import org.brickred.socialauth.android.SocialAuthError;
import org.brickred.socialauth.android.SocialAuthListener;
import org.brickred.socialauth.android.SocialAuthAdapter.Provider;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import com.facebook.Session;
import com.facebook.SessionState;
public class LoginActivity extends Activity {
SocialAuthAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
adapter=new SocialAuthAdapter(new DialogListener() {
@Override
public void onError(SocialAuthError arg0) {
Log.e("Login activity", arg0.getMessage());
}
@Override
public void onComplete(Bundle arg0) {
adapter.getUserProfileAsync(new SocialAuthListener<Profile>() {
@Override
public void onExecute(String arg0, Profile arg1) {
Log.d("Custom-UI", "Receiving Data");
Profile profileMap = arg1;
Log.d("Custom-UI", "Validate ID = " + profileMap.getValidatedId());
Log.d("Custom-UI", "First Name = " + profileMap.getFirstName());
Log.d("Custom-UI", "Last Name = " + profileMap.getLastName());
Log.d("Custom-UI", "Email = " + profileMap.getEmail());
Log.d("Custom-UI", "Gender = " + profileMap.getGender());
Log.d("Custom-UI", "Country = " + profileMap.getCountry());
Log.d("Custom-UI", "Language = " + profileMap.getLanguage());
Log.d("Custom-UI", "Location = " + profileMap.getLocation());
Log.d("Custom-UI", "Profile Image URL = " + profileMap.getProfileImageURL());
}
@Override
public void onError(SocialAuthError arg0) {
// TODO Auto-generated method stub
}
});
}
@Override
public void onCancel() {
// TODO Auto-generated method stub
}
@Override
public void onBack() {
// TODO Auto-generated method stub
}
});
// adapter.addProvider(Provider.FACEBOOK, R.drawable.facebook);
// adapter.addProvider(Provider.GOOGLE, R.drawable.google);
// adapter.addProvider(Provider.TWITTER, R.drawable.twitter);
Button skip=(Button) findViewById(R.id.btnSkip);
skip.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent mainIntent=new Intent(LoginActivity.this, MainActivity.class);
startActivity(mainIntent);
}
});
ImageView imgFacebook=(ImageView) findViewById(R.id.imageView3);
imgFacebook.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
adapter.authorize(LoginActivity.this, Provider.FACEBOOK);
}
});
ImageView imgGoogle=(ImageView) findViewById(R.id.imageView4);
imgGoogle.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
adapter.addCallBack(Provider.GOOGLE,"http://socialauth.in/socialauthdemo");
adapter.authorize(LoginActivity.this, Provider.GOOGLE);
}
});
ImageView imgTwitter=(ImageView) findViewById(R.id.imageView5);
imgTwitter.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
adapter.addCallBack(Provider.TWITTER,"http://socialauth.in/socialauthdemo/socialAuthSuccessAction.do");
adapter.authorize(LoginActivity.this, Provider.TWITTER);
}
});
}
}
I have tried commenting and uncommenting the adapter.addprovider() lines but the problem persists. Facebook and Twitter work perfectly fine but there is some trouble with Google. I have added the client-id and api key that were generated in the credentials to oauth_consumer.properties. Any help is greatly appreciated. thanks in advance.