Issue facing in Google Email Migration API - google-email-migration

I am using Google Email Migration API to migrate mails from Yahoo mailbox to Gmail.
Using Google Email Migration API, I got the access token of a particular user and I am using the below API to migrate mail:
https://www.googleapis.com/upload/email/v2/users/somemailid#gmail.com/mail?uploadType=multipart
I am sending a Multipart request to the above API, I am receiving response as:
Invalid multipart request with 0 mime parts.
Please let me know how to solve this.

Related

How to receive a verification token for single sender in sendgrid

I can see in sendgrid API we have a call to verify a single sender with a token
https://docs.sendgrid.com/api-reference/sender-verification/verify-sender-request
but I can't find a way to actually receive this token from anywhere, the only way is by sending an email that needs authentication (and we fall into this issue verifying sender email requires user to log in to sendgrid)
Anyone actually used this route in a way ?
There is a workaround as follows:
The link in the email redirects to a URL that looks like this https://app.sendgrid.com/settings/sender_auth/senders/verify?token=xyz, with the token query parameter. You can use that token in the api call to verify the sender email using your own api credentials.

PayPal REST API: "Client Authentication failed" in sandbox mode

I am currently trying to implement the paypal api to get the details of an order, but it shows me the following error:
Uncaught PayPalHttp\HttpException: {"error":"invalid_client","error_description":"Client Authentication failed"} in vendor/paypal/paypalhttp/lib/PayPalHttp/HttpClient.php on line 215
I am using the data that paypal gives me of the client id and the secret that is checked in: https://developer.paypal.com/developer/applications/ following the official documentation, after i set up my server to make calls to PayPal, im currently following this guide: https://developer.paypal.com/docs/checkout/reference/server-integration/get-transaction/
I've been trying to find the solution for two days without much success, do you know why paypal marks this error?
As a note, I am still in sandbox (the client and the secret are from the sandbox too) and I am using the default application created by paypal, does it have something to do with it?
It appears the request for an access token is failing, but we cannot comment specifically without seeing a full request+response log added to your question's details.
Ensure you are connecting to api(-m).sandbox.paypal.com with HTTP basic authentication ("Authentication: Basic ..." header) that has a base64 encoded clientid:secret of a Sandbox REST API app, and that the POST data is grant_type=client_credentials
Documentation: https://developer.paypal.com/docs/api/overview/#get-credentials

Firebase Cloud Messaging with Android

I want to integrate Firebase cloud messaging with Android. I have created my account on Firebase and integrated with the app and have sent a message from Firebase console. The app received the message. So far, things like this seem working.
My question is that how can I connect Firebase with my own database server, which is consisting of MongoDB, to check for the data of users against to whom a notification is to be sent? Can some one guide me please?
There are quite a number of steps, it is probably too long to post here, but since you just asked for guidance, I'll try to run through the steps involved.
Your Android app will need to send its FCM token the server running your MongoDB instance. Referencing this FCM documentation page, you'll need to implement sendRegistrationToServer(refreshedToken); in the onTokenRefresh() method.
Your server will need to be listening for clients sending their FCM token. This could be an HTTP endpoint listening for POST requests with a client token and username. It can then store the details in your database. (Remember to use HTTPS where possible.)
Enable the Cloud Messaging API: https://console.developers.google.com/apis/api/fcm.googleapis.com/overview?project=insert-project-id-here
You can send FCM messages from the server running MongoDB using the Firebase HTTP v1 API, but first you'll need to authorize your server to do so. Instructions here. You will get an authorisation token that needs to be included in the HTTP header of all API requests.
Once you have a valid token you can send an HTTP POST request to https://fcm.googleapis.com/v1/{parent=projects/*}/messages:send, where the body contains details of the message. This page contains a description of the API endpoint. This page contains a description of the message body to send.
As a brief (currently untested) example of a POST request. If you're project id was fcm-test-12345, you would make a POST request to:
https://fcm.googleapis.com/v1/projects/fcm-test-12345/messages:send
The header should contain:
Authorization: Bearer <your access token>
Content-Type: application/json
And the body would be something like this:
{
"message": {
"data": { "key": "value" }, // optional data to send to client.
"notification": {
"title": "Notification title",
"body": "Notification body"
},
"token": "<client device token from MongoDB>"
}
}

Get messages from Gmail via HTTPS GET call

I'm working on an iOS application and what I'd like to do is have the app ping one universal Gmail account to check for the most recent email.
I went through the guide from Google at https://developers.google.com/gmail/api/quickstart/ios?ver=swift, but the result did not work. After some googling, it appears that some functionality may have been changed, but they haven't updated their documentation yet.
Is there a way to send credentials via https to Gmail and get email messages back? I have an OAuth key via the Gmail API manager, but when I pass it as "access_token", the response says "Login Required".
AFAIK, an error response "Login Required" can be encountered if you try to list the buckets for a project that do not provide an authorization header.
If we check Users.messages: get, it's noted that it requires authorization.
For this, you may want to check Authorizing Your App with Gmail wherein you will find these basic authorization pattern:
During development, register the application in the Google API Console.
When the app launches, request that the user grant access to data in their Google account.
If the user consents, your application requests and receives credentials to access the Gmail API.
Refresh the credentials (if necessary).
Furthermore, if your application needs to access Google APIs on behalf of the user, you should use server-side flow. Please see Implementing Server-Side Authorization for more information.
Sometime back I was involved in writing a sample application to access email from gmail but using C++ on windows. The code is at https://github.com/Panchatcharam/simple_gmail_api. I was able to successfully get emails.

SendGrid incoming mail webhook - how do I secure my endpoint

I'm currently using SendGrid's Inbound Parse Webhook to feed emails to my application. I've been able to get it working by pointing the URL to an endpoint which my application has exposed. SendGrid just sends the email in the form of a JSON format HTTP POST request to this endpoint and I just process each request internally.
My question is, now that I have it working, how do I ensure that only SendGrid can use this endpoint? At the moment, anyone can utilise this HTTP POST endpoint and pretend that an email has been sent to the application.
Can I get SendGrid to send some sort of unique key to identify themselves? Is there a way I can restrict by ip address?
There are two ways which you may secure your endpoint. SendGrid's webhooks support basic auth (e.g. https://user:pass#example.com/endpoint). You can also implement a unique key, that you check before acting upon the request (e.g. https://example.com/endpoint?key=123).
The simple answer, however, is anything that you add to the URL can act as unique authentication for SendGrid.