在网站https://code.google.com/apis/console上我已经注册了我的应用程序,为我的应用设置了生成的客户端ID:和客户端密钥,并尝试使用Google登录.不幸的是,我收到了错误消息:
Error: redirect_uri_mismatch
The redirect URI in the request: http://127.0.0.1:3000/auth/google_oauth2/callback did not match a registered redirect URI
scope=https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
response_type=code
redirect_uri=http://127.0.0.1:3000/auth/google_oauth2/callback
access_type=offline
approval_prompt=force
client_id=generated_id
Run Code Online (Sandbox Code Playgroud)
这条消息是什么意思,我该如何解决?我使用gem omniauth-google-oauth2.
我正在尝试使用Java发送电子邮件:
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class SendEmail {
public static void main(String [] args) {
// Recipient's email ID needs to be mentioned.
String to = "abcd@gmail.com";
// Sender's email ID needs to be mentioned
String from = "web@gmail.com";
// Assuming you are sending email from localhost
String host = "localhost";
// Get system properties
Properties properties = System.getProperties();
// Setup mail server
properties.setProperty("mail.smtp.host", host);
// Get the default Session object.
Session session = Session.getDefaultInstance(properties); …Run Code Online (Sandbox Code Playgroud) 我想从我的应用程序发送一封电子邮件,我写了以下代码来发送邮件
MailMessage msg = new MailMessage();
msg.From = new MailAddress("mymailid");
msg.To.Add("receipientid");
msg.Subject = "test";
msg.Body = "Test Content";
msg.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
client.Credentials = new NetworkCredential("mymailid", "mypassword", "smtp.gmail.com");
client.Host = "smtp.gmail.com";
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
client.UseDefaultCredentials = true;
client.Send(msg);
Run Code Online (Sandbox Code Playgroud)
我在localhost上运行它,所以我正在做什么错误发送它.
当我发送按钮时,它给出了一个错误
SMTP服务器需要安全连接或客户端未经过身份验证.服务器响应为:5.5.1需要身份验证.
Web.config文件中的代码
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="smtpServer" value="smtp.gmail.com" />
<add key="EnableSsl" value …Run Code Online (Sandbox Code Playgroud) 情况:
我正在为我的应用测试Gmail API.
我已经测试了一些请求,它们工作正常.例如获取消息,获取用户历史记录,获取草稿列表等.
基本上所有只读请求都正常工作.
我有一些与其他请求的权限相关的问题,例如当我必须写或删除草稿时.
这是我得到的错误:
(403) Insufficient Permission
Run Code Online (Sandbox Code Playgroud)
代码:
这是初始化应用程序的功能:
public function gmail_init_service()
{
$client = new Google_Client();
$client->setApplicationName("Gmail API test");
$client->setDeveloperKey("MY_KEY");
$client->setClientSecret('MY_CLIENT_SECRET');
$client->SetClientId('MY_CLIENT_ID');
$client->setScopes(array('https://mail.google.com/'));
$client->setAccessToken('{"access_token":"MY_ACCESS_TOKEN","token_type":"Bearer","expires_in":3600,"refresh_token":"MY_REFRESH_TOKEN","created":1433502343}');
$service = new Google_Service_Gmail($client);
return $service;
}
Run Code Online (Sandbox Code Playgroud)
这是删除一个草稿的请求:
public function gmail_delete_draft()
{
$service = $this->gmail_init_service();
// --------------- Get draft list --------------
$list = $service->users_drafts->listUsersDrafts('me');
$draftList = $list->getDrafts();
// --------------- Get draft IDs ---------------
$inbox_draft = [];
foreach($draftList as $mlist)
{
$draftId = $mlist->id;
$optParamsGet2['format'] = 'full';
$single_message = …Run Code Online (Sandbox Code Playgroud)