Google OAuth Login Demo

Click the button below to login with your Google account:

Sign in with Google
Debug Info:
Session ID: fr6263tfnrqnvrmad5e346nrso
Session State Set: Yes (9dcd06440fc839b6fa4316e79af2af3a)
Cookie State Set: No
Current URL: /
Server Name: dveasy.com
HTTPS: Yes
Session Save Path: /tmp/php_sessions
Session Save Path Writable: Yes
PHP Session Module: files
Test Session
Configuration Check:
Client ID Set: ✓ Yes
Client Secret Set: ✓ Yes
Redirect URI: https://www.dveasy.com/index.php
Database Host: srv1387.hstgr.io
Database Name: u669301026_jazz
cURL Available: ✓ Yes
allow_url_fopen: ✓ Enabled
Outbound HTTPS (file_get_contents): ✗ Blocked
Outbound HTTPS (cURL): ✓ Working

Setup Instructions:

  1. Google Console Setup:
    • Go to Google Developers Console
    • Create a new project or select existing one
    • Enable the "Google+ API" and "Google OAuth2 API"
    • Go to "Credentials" → "Create Credentials" → "OAuth 2.0 Client ID"
    • Add your domain to authorized redirect URIs
    • Copy your Client ID and Client Secret
  2. Database Setup:
    • Create a MySQL database
    • Update the database configuration variables at the top of this file
  3. Configuration:
    • Update $google_client_id and $google_client_secret
    • Update $redirect_uri to match this file's URL
    • Update database connection details

Troubleshooting "Outbound HTTPS Blocked" Error:

Your server cannot make HTTPS requests to external sites (like Google). This is a common hosting restriction.

Solutions (in order of preference):

  1. Contact Your Hosting Provider:
    • Ask them to enable outbound HTTPS requests
    • Request they whitelist Google's OAuth endpoints: *.googleapis.com
    • This is the best long-term solution
  2. Enable cURL (if available):
    • The code now automatically tries cURL as a fallback
    • Check if "cURL Available" shows green in the debug info above
    • Some hosts block file_get_contents but allow cURL
  3. Use a Proxy Service:
    • Set up a proxy on another server that can make HTTPS requests
    • Route your OAuth requests through the proxy
  4. Move to a Different Host:
    • Consider VPS hosting (DigitalOcean, Linode, AWS)
    • Most modern hosting providers allow outbound HTTPS
  5. Alternative: Server-Side Proxy Script:
    • Create a proxy script on a different server
    • Have your main server communicate with the proxy via HTTP

Quick Tests to Try:

Hosting Provider Specific Solutions:

Note: This is a server configuration issue, not a code problem. The OAuth flow requires your server to communicate with Google's servers.

Troubleshooting "Failed to get access token" Error:

Troubleshooting "Failed to get access token" Error:

This error occurs during the token exchange with Google. Common causes: Google Console Checklist:
  1. Go to Google Console Credentials
  2. Click on your OAuth 2.0 Client ID
  3. Check "Authorized redirect URIs" - it must include: https://www.dveasy.com/index.php
  4. Make sure both "Google+ API" and "Google People API" are enabled in your project
  5. Verify you're using the correct Client ID and Secret from the right project
Quick fixes:

Troubleshooting "Session expired" Error:

If you're getting "oauth_state not found in session" error: Quick session tests:
  1. Test sessions work: Add $_SESSION['test'] = 'working'; at the top, then refresh and check if it persists.
  2. Check permissions: Make sure the session directory has proper write permissions (755 or 777).
  3. Try different browser: Test in a completely different browser.
  4. Check server logs: Look for PHP errors in your server's error log.
Alternative solutions: