首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google +使用android中社交软件库的集成

Google +使用android中社交软件库的集成
EN

Stack Overflow用户
提问于 2013-11-29 14:35:13
回答 1查看 2.5K关注 0票数 0

我已经成功地整合了facebook,使用社交网站twitter,但是我在整合google +整合时遇到了问题,我可以登录,但是不能分享任何东西。

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

如果有人有想法,请回复。

提前谢谢..。

我使用的代码如下:

身份验证:-

代码语言:javascript
复制
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();
           }

共享:-

代码语言:javascript
复制
        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)
        {

        }
EN

回答 1

Stack Overflow用户

发布于 2014-01-22 17:47:34

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

步骤:

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

所以在你的代码中:

代码语言:javascript
复制
googlePlusAdapter.addCallBack(Provider.GOOGLEPLUS, "http://localhost");

你必须这样写:

代码语言:javascript
复制
googlePlusAdapter.addCallBack(Provider.GOOGLEPLUS, same_uri_you_put_in_redirect_uri);

这是因为社交网站通过http认证。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20288079

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档