What's new

How can I make google login api for xenforo?

aior

Administrator
Staff member
XenForo, as a forum software, has built-in functionalities for social media logins including Google. However, in case you're looking to create your own Google login API for XenForo, you would need to follow a series of steps involving creating a project on Google Cloud Console, enabling Google+ API, generating credentials, and finally integrating them into XenForo. Please note that the actual implementation could change slightly depending on the version of XenForo and the changes Google makes to their Cloud Console.

Here are the steps that are generally involved:

1. **Create a Project on Google Cloud Console**
- Visit the Google Cloud Console: https://console.cloud.google.com/.
- Click on "Select a project" or "Create Project" if you haven't any.
- Give your project a name and click "Create".

2. **Enable Google+ API**
- Once your project is created, you'll be redirected to the dashboard.
- Click on "Enable APIs and Services".
- Search for "Google+ API" and enable it. (Google has transitioned Google+ APIs to Google People API, use that if Google+ is unavailable)

1687510778867.png

3. **Create Credentials**
- After enabling the Google People API, go back to the Dashboard.
- Click on "Credentials" in the left-hand menu.
- Click on the "Create Credentials" button and choose "OAuth client ID".
- If you haven't configured the OAuth consent screen yet, you'll be prompted to do so.
- On the "OAuth consent screen" page, fill in the required fields. In the "User Type" section, choose "External" then "Create".
- Now, back in "Credentials", click on "Create Credentials" again and choose "OAuth client ID".
- For the Application type, choose "Web application".
- Under "Authorized redirect URIs", you'll need to enter your XenForo's Google callback URL. This is usually in the format `http://yourforum.com/register/google?assoc=1`.
- Click on "Create" to generate your credentials.

1687510916254.png

Adjust your redirected url from Google Consol as below:

Code:
https://yourxenforolink.com/connected_account.php

1687511122182.png

Then click create button and you will get Google Login Cliend ID and Client Secret as below:

1687511207698.png

4. **Integrate into XenForo**
- Go back to your XenForo forum Admin Panel.
- Navigate to "Setup" > "Options" > "Connected accounts" > "Google"
- Enter the Client ID and Client Secret that were generated in the Google Cloud Console.
- Save the changes.

Now, your users should be able to sign in to your XenForo forum using their Google accounts.

Then you will be able to use google for login as below:

1687511445613.png

If you try to login with an ellready registered account first time you will get an error like below:

1687511526208.png

Oops! We ran into some problems.​


The email address linked to this Google account belongs to another member's account on Artificial Intelligence Optimization Researches. Please log into that Artificial Intelligence Optimization Researches account to associate with Google.

It means that you need to connect your accounts as below: Use register option will not work as below:

1687511647927.png

Continue with register with google option:

1687511687338.png

Same failure:

1687511751636.png


Solution for allready existing members:

Method 1: Associate your existing account with Google

If you are the owner of the existing account with that email, then you can simply associate your Google account with your forum account.

  1. Log in to your forum account using the existing username and password.
  2. Navigate to your account settings or preferences.
  3. Look for a section related to "Connected Accounts" or "Social Accounts".

1687512040702.png
  1. Here, you should see an option to associate your account with a Google account.
  2. Follow the prompts to log in with your Google account and connect it to your existing forum account.

1687512670337.png

Once this is done, you should be able to use the "Log in with Google" feature without receiving the error message.

Use you password last time for login and continue with assosiate button.

1687512739484.png


You will see that your account is connected as below:

1687512871131.png

Next time you will be able to use Google login option with xenforo without any problem. You can log out and login again to test it.


Method 2: Create a new account with a different email address

If you do not have access to the existing forum account with the conflicting email address, you will need to use a different email address for your new account. In this case, you could:

  1. Create a new Google account with a different email address, or
  2. Use a different email address (that isn't associated with an account on the forum) to create a new Google account.
Then, use this new Google account to log in via the Google login feature on the forum.
 
Last edited:
Back
Top