Socialauth API 4.3 with Google Oauth 2.0

此生再无相见时 提交于 2019-12-06 07:12:21

问题


Does anyone know how to use Brickred Socialauth API 4.3 in servlets with Google Oauth 2.0? Where could I get the *consumer_secret* and *consumer_key*?

Was using the API successful at your side?


回答1:


The instructions available on the BrickRed wiki no longer work as you have already found out. The following should work assuming:

A. You are using socialauth 4.2+. I tested these with socialauth 4.4.
B. You are trying to configure your own domain and not using the brickred domain for testing.
C. You are creating a web application, else adjust accordingly

  1. First register your application on Google Cloud console:
    a. Go to https://cloud.google.com/console/project
    b. Login
    c. Create a new project
    d. APIs & Auth > Credentials
    e. Create New Client ID ( Application Type: Web Application, Authorized redirect URL: http://YOUR_HOST_NAME/socialauth.html)
  2. Modify brickred properties.xml
    Replace
    <prop key="www.google.com.consumer_key">opensource.brickred.com</prop>
    <prop key="www.google.com.consumer_secret">YC06FqhmCLWvtBg/O4W/aJfj</prop>

    with

    <prop key="googleapis.com.consumer_key">CLIENT ID created in Step 1.e above</prop>
    <prop key="googleapis.com.consumer_secret">Client Secret created in Step 1.e above </prop>

If you are not using Spring, modify oauth_consumer.properties

Modify the link in your application where the user clicks on to start the contacts import process:
change
?id=google

to

?id=googleplus

Hope this helps




回答2:


You can register your app to use Google OAuth at:

https://developers.google.com/accounts/docs/OAuth2Login#registeringyourapp

from where you get your "secret / key".

I have successfully implemented SocialAuth with Facebook and it worked properly. I still don't have any experience implementing it with google OAuth2 but it should work. Their CDI example does authenticate with Google, I am just not sure if using Oauth1 or Oauth2.

Regards.




回答3:


For people who cannot find the consumer_secret, I found a solution:

socialauth is using web flow. So if you are socialauth-android you need to create web application instead of installed application.

So even for an Android App, you still need create a Client ID for web project. The secret will be displayed in page directly!



来源:https://stackoverflow.com/questions/20932793/socialauth-api-4-3-with-google-oauth-2-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!