gpt4 book ai didi

java - oauth_consumer.properties 未找到社交身份验证 android

转载 作者:行者123 更新时间:2023-12-02 04:54:47 24 4
gpt4 key购买 nike

我正在使用SocialAuth用于使用 FacebookTwitterGoogle 进行身份验证的用户的库。我有一些问题。

我在 log cat 中收到以下错误

D/SocialAuthAdapter﹕ Selected provider is facebook
D/SocialAuthAdapter﹕ Loading keys and secrets from configuration
D/SocialAuthAdapter﹕ oauth_consumer.properties not found
D/SocialAuthAdapter﹕ Could not load configuration
D/SocialAuthAdapter﹕ Starting webview for authentication
D/SocialAuthError﹕ org.brickred.socialauth.exception.SocialAuthConfigurationException: SocialAuth configuration is null.
E/Login activity﹕ URL Authentication error

下面是我的文件夹结构

enter image description here

我的LoginActivity.java

public class LoginActivity extends ActionBarActivity {

private SocialAuthAdapter adapter;

//Android Component
private Button fb_button, tw_button, g_button;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.activity_login);

//Social Adapter
adapter = new SocialAuthAdapter(new DialogListener() {
@Override
public void onComplete(Bundle bundle) {
adapter.getUserProfileAsync(new SocialAuthListener<Profile>() {
@Override
public void onExecute(String s, Profile profile) {
Log.e("Custom UI", "Login Receiving Data");
Profile profileMap = profile;
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 socialAuthError) {
Log.e("Custom UI", "Profile Data Error");
}
});
}

@Override
public void onError(SocialAuthError socialAuthError) {
Log.e("Login activity", socialAuthError.getMessage());
}

@Override
public void onCancel() {

}

@Override
public void onBack() {

}
});


//Wire up the Login Buttons
fb_button = (Button) findViewById(R.id.buttonFB);
tw_button = (Button) findViewById(R.id.buttonTwitter);
g_button = (Button) findViewById(R.id.buttonGoogle);

//Event Listener for Click

//Facebook
fb_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
adapter.authorize(LoginActivity.this, SocialAuthAdapter.Provider.FACEBOOK);
Toast.makeText(LoginActivity.this, "I am Facebook", Toast.LENGTH_SHORT).show();
}
});

//Twitter
tw_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
adapter.addCallBack(SocialAuthAdapter.Provider.TWITTER,"http://domain.com/auth/twitter");
adapter.authorize(LoginActivity.this, SocialAuthAdapter.Provider.TWITTER);
Toast.makeText(LoginActivity.this, "I am Twitter", Toast.LENGTH_SHORT).show();
}
});

//Google
g_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
adapter.addCallBack(SocialAuthAdapter.Provider.GOOGLE,"http://domain.com/google");
adapter.authorize(LoginActivity.this, SocialAuthAdapter.Provider.GOOGLE);
Toast.makeText(LoginActivity.this, "I am Google", Toast.LENGTH_SHORT).show();
}
});

}

}

应用程序中callback url的用途是什么。回调网址上会发布什么内容?

如何才能仅在第一次时显示此登录屏幕?

一种方法是SharedPreference来存储登录用户的设置,SocialAuth库中有什么方法可以做到这一点。

感谢这个库,它很棒,但文档还有待改进。

最佳答案

在我敲了整整两天的头之后,我发现了错误

您需要将 assets 文件夹与 res 文件夹放在同一级别,才能加载 oauth_consumer.properties 文件。

src
main
assets
java
res
AndroidManifest.xml

关于java - oauth_consumer.properties 未找到社交身份验证 android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28897716/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com