Invalid parameter value for redirect_uri: Missing scheme: insert_your_oauth2_redirect_uri

1,731 views
Skip to first unread message

Lukas Bollinger

unread,
Oct 16, 2013, 12:10:02 PM10/16/13
to google-api...@googlegroups.com
Hello

I have copied the php code of the tutorial to test the google api, but now every time I want to connect following error appears:

Invalid parameter value for redirect_uri: Missing scheme: insert_your_oauth2_redirect_uri

details:


Redirect URIs: http://seite.de/googleapi.php

JavaScript origins: http://seitet.de


copied php-code: (googleapi.php)

<?php
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_PlusService.php';

// Set your cached access token. Remember to replace $_SESSION with a
// real database or memcached.
session_start();

$client = new Google_Client();
$client->setApplicationName('Google+ PHP Starter Application');
// Visit https://code.google.com/apis/console?api=plus to generate your
// client id, client secret, and to register your redirect uri.
$client->setClientId('insert_your_oauth2_client_id');
$client->setClientSecret('insert_your_oauth2_client_secret');
$client->setRedirectUri('insert_your_oauth2_redirect_uri');
$client->setDeveloperKey('insert_your_simple_api_key');
$plus = new Google_PlusService($client);

if (isset($_GET['code'])) {
  $client->authenticate();
  $_SESSION['token'] = $client->getAccessToken();
  $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
  header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
}

if (isset($_SESSION['token'])) {
  $client->setAccessToken($_SESSION['token']);
}

if ($client->getAccessToken()) {
  $activities = $plus->activities->listActivities('me', 'public');
  print 'Your Activities: <pre>' . print_r($activities, true) . '</pre>';

  // We're not done yet. Remember to update the cached access token.
  // Remember to replace $_SESSION with a real database or memcached.
  $_SESSION['token'] = $client->getAccessToken();
} else {
  $authUrl = $client->createAuthUrl();
  print "<a href='$authUrl'>Connect Me!</a>";
}



Hope you can help me. Oh well I am German, so please not to comlicate :D

Reply all
Reply to author
Forward
0 new messages