【问题标题】:Google plus integration using social auth library in android在 android 中使用社交身份验证库的 Google plus 集成
【发布时间】:2013-11-29 14:35:13
【问题描述】:

我已经使用社交身份验证成功集成了 facebook、twitter, 但是我在集成 google plus 集成时遇到问题。我可以登录但无法共享任何内容。

错误:- org.brickred.socialauth.exception.SocialAuthException: java.io.FileNotFoundException: https://accounts.google.com/o/oauth2/token

如果有人知道请回复。

提前谢谢....

我正在使用以下代码:-

身份验证:-

SocialAuthAdapter googlePlusAdapter;

    try
            {
                            googlePlusAdapter = new SocialAuthAdapter(new ResponseListener());
                            googlePlusAdapter.addCallBack(Provider.GOOGLEPLUS, "http://localhost");
                            googlePlusAdapter.authorize(this,org.brickred.socialauth.android.SocialAuthAdapter.Provider.GOOGLEPLUS);
            } catch (Exception e) {

                            Toast.makeText(getApplicationContext(),"Exception " + e.toString(), 1).show();
           }

分享:-

        try{

             String msg="post from my app"; 

        googlePlusAdapter.updateStatus(msg, new SocialAuthListener<Integer>() {

            @Override
            public void onExecute(String arg0, Integer t) {
                // TODO Auto-generated method stub
                Integer status = t;
                if (status.intValue() == 200 || status.intValue() == 201 ||status.intValue() == 204)
                {    Toast.makeText(getApplicationContext(), "Message posted",Toast.LENGTH_LONG).show();
                     googlePlusAdapter.signOut(Provider.GOOGLEPLUS.toString()); 
                }
                else
                Toast.makeText(getApplicationContext(), "Message not posted",Toast.LENGTH_LONG).show();
            }

            @Override
            public void onError(SocialAuthError error) {
                // TODO Auto-generated method stub
                Toast.makeText(getApplicationContext(), "Message not posted!! Try again",Toast.LENGTH_LONG).show();
            }
        }, true);

        finish();
        }
        catch(Exception e)
        {

        }

【问题讨论】:

  • 你能解决这个问题吗?我也有同样的问题。我认为问题出在这行: googlePlusAdapter.addCallBack(Provider.GOOGLEPLUS, "localhost"); 但是如果你评论那行你会得到一个redirect_uri_mismatch,我找不到在我的谷歌应用程序中修改该字段的方法( cloud.google.com/console/project).
  • 不,我在没有社交身份验证的情况下完成了。 stackoverflow.com/questions/16461345/…

标签: android authentication google-plus social


【解决方案1】:

问题是您已经为 Android 应用程序创建了一个客户端 ID。 您必须为 Web 应用程序创建一个客户端 ID,然后在该选项中您必须分配一个 redirect_uri。

步骤:

  1. 转到https://cloud.google.com/console/project
  2. 选择您的项目
  3. 选择 API 和身份验证,然后选择凭据
  4. 按 Crate 新客户端 ID
  5. 创建一个 Web 应用程序类型。
  6. 放置一个可以响应 YOUR_URL/oauth2callback 的有效 uri

所以在你的代码中:

googlePlusAdapter.addCallBack(Provider.GOOGLEPLUS, "http://localhost");

你必须这样写:

googlePlusAdapter.addCallBack(Provider.GOOGLEPLUS, same_uri_you_put_in_redirect_uri);

这是因为 socialauth 通过 http 进行身份验证。

【讨论】:

  • 我们是否必须在 YOUR_URL/oauth2callback 中添加一些内容?
猜你喜欢
  • 2015-12-05
  • 1970-01-01
  • 2011-12-13
  • 2019-09-20
  • 2016-02-21
  • 2015-05-07
  • 2018-04-04
  • 1970-01-01
相关资源
最近更新 更多