在web.config文件中的行:web.config文件行拒絕訪問谷歌的OAuth登錄
<authorization>
<deny users="?" />
</authorization>
拒絕訪問谷歌的OAuth登錄(使用OAuthWebSecurity)。 當我們評論這些行時它的工作原理,但有人在這裏說出於安全原因需要這些行。
是否有任何其他方式讓Google OAuth登錄工作而不發表評論?
在web.config文件中的行:web.config文件行拒絕訪問谷歌的OAuth登錄
<authorization>
<deny users="?" />
</authorization>
拒絕訪問谷歌的OAuth登錄(使用OAuthWebSecurity)。 當我們評論這些行時它的工作原理,但有人在這裏說出於安全原因需要這些行。
是否有任何其他方式讓Google OAuth登錄工作而不發表評論?
我的OAuth沒有任何代碼:P(使用PHP)
這下面的代碼使用的OAuth2.0的連接進行驗證,它創建您採摘的選擇谷歌日曆事件,用一個簡單的形式添加事件細節。
測試後,我有這個工作&也不同版本,其中事件的詳細信息通過外部形式傳遞變量和連接正在使用的服務帳戶,而不是OAuth2.0的
好運。
<?php
require_once '../google-api-php-client/src/Google_Client.php';
require_once '../google-api-php-client/src/contrib/Google_CalendarService.php';
session_start();
$client = new Google_Client();
$client->setApplicationName("Google Calendar PHP Event Creator");
$client->setClientId('YOUR CLI ID HERE.apps.googleusercontent.com');
$client->setClientSecret('YOUR CLI SECRET HERE');
$client->setRedirectUri('THIS FILE LOCATION HERE');
$client->setDeveloperKey('API key here');
$cal = new Google_CalendarService($client);
if (isset($_GET['logout'])){
unset($_SESSION['token']);
}
if (isset($_GET['code'])){
$client->authenticate($_GET['code']);
$_SESSION['token'] = $client->getAccessToken();
header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
if (isset($_SESSION['token'])){
$client->setAccessToken($_SESSION['token']);
}
if ($client->getAccessToken()){
$calList = $cal->calendarList->listCalendarList();
if(isset($_POST['action'])){
$action = $_POST['action'];
if($action == "addCalEvent"){
$title = $_POST["title"];
$desc = $_POST["desc"];
$calID = $_POST["calID"];
$locat = $_POST["locat"];
$from = $_POST["from"];
$until = $_POST["until"];
//Set the Event data
$event = new Google_Event();
$event->setSummary($title);
$event->setDescription($desc);
$event->setLocation($locat);
$start = new Google_EventDateTime();
$start->setDateTime($from);
$event->setStart($start);
$end = new Google_EventDateTime();
$end->setDateTime($until);
$event->setEnd($end);
$createdEvent = $cal->events->insert('YOUR CALENDAR ID [email protected]', $event);
echo $createdEvent->getId();
}
}
print "<div style='width:100%;height:100%;'><div style='width:550px;height:320px;text-align:center;margin:200px auto;background-color:#f0ffff;border:1px solid black;'><div style='padding:50px;'><table>";
print "<form action='caladd.php' method='POST'>";
print "<tr><td>Title: </td><td><input type='text' name='title' id='title'></td></tr>";
print "<tr><td>Desc: </td><td><input type='text' name='desc' id='desc'></td></tr>";
print "<tr><td>Location: </td><td><input type='text' name='locat' id='locat'></td></tr>";
print "<tr><td colspan='2'>Date Format: YYYY-MM-DDTHH:MM:SS(.000)-00:00 (.000 = Optional)</td></tr>";
print "<tr><td>From: </td><td><input type='text' name='from' id='from'></td></tr>";
print "<tr><td>To: </td><td><input type='text' name='until' id='until'></td></tr>";
print "<tr><td>Select Calendar: </td><td><select name='calID' id='chooseCal'>";
for($i=0; $i < count($calList['items']); $i++)
{
print "<option value=".$calList['items'][$i]['id']."'>".$calList['items'][$i]['summary']."</option>";
}
print "</select></br></td></tr>";
print "<input type='hidden' name='action' value='addCalEvent'>";
print "<tr><td colspan='2'><div style='text-align:right;'><input type='submit' value='Submit'></div></td></tr>";
print "</form>";
print "</table></div></div></div>";
$_SESSION['token'] = $client->getAccessToken();
}
else
{
$authUrl = $client->createAuthUrl();
print "<a class='login' href='$authUrl'>Create a Google Calendar Event?</a>";
print "<a href='/'>Exit to Homepage</a>";
}
?>
之間的關係,閱讀您的問題......我明白,我誤以爲是...我不知道在web.config文件沒有看。這個是來做什麼的? –
我很感謝你的努力。我問的是關於ASP .NET的配置文件web.config。看到你的代碼。我有點想念PHP :) – user3248895
我剛開始自己學習它從我的工作在線視頻教程:P 大聲笑,我從瞭解PHP 0到編程自定義Google地圖JSON - > API - > XML - >自定義谷歌地圖結果....這是一個殺手! 從那時起我就變得非常喜歡PHP,我認爲它的PHPantastic,*哦,親愛的*,我想到的可怕的punn。 我喜歡將PHP與JS,HTML和CSS混合來製作一些非常酷的動態內容,最好的部分就是PHP對用戶是隱藏的! –
我沒有看到谷歌的OAuth和第二個想法ASP.NET驗證 – Andrei