App Engine: Are the headers like X-AppEngine-Country always non-null? - google-app-engine

I want to use the headers X-AppEngine-Country and X-AppEngine-Region but i've heard that they're not always populated with non-null values in every request?
Is that true, or can i rely on them to always have values?
I cannot find documentation that says one way or the other.

From Request headers:
X-AppEngine-Country
Country from which the request originated, as an ISO 3166-1 alpha-2 country code. App Engine determines this code from the
client's IP address. Note that the country information is not derived
from the WHOIS database; it's possible that an IP address with country
information in the WHOIS database will not have country information in
the X-AppEngine-Country header. Your application should handle the
special country code ZZ (unknown country).
X-AppEngine-Region
Name of region from which the request originated. This value only makes sense in the context of the country in X-AppEngine-Country. For
example, if the country is "US" and the region is "ca", that "ca"
means "California", not Canada. The complete list of valid region
values is found in the ISO-3166-2 standard.

Related

Sending to another user with e-mail address

I am trying to create a script in Python to transfer funds to another Coinbase user when all I have is an e-mail address. I have been unsuccessful so far. How do I get another user's "id" when all I have is their e-mail address?
As a follow on, can I add a memo/note to the transfer? If so, how?
Finally figured it out with a little bit more searching and trial and error. For anyone else who may have this question:
First get the account ID for the currency you want to send.
account_list = client.get_accounts()['data']
ETH_id = [acc['id'] for acc in account_list if acc['balance']['currency'] == "ETH"][0]
Then use the send_money function (not transfer_money) to send to an e-mail address.
client.send_money(ETH_id,to="<e-mail address>", amount="0.0005", currency="ETH", description = "Hey look, it worked.")
The description keyword is for the memo.

Converting from BTC to another currency

From Coinbase API can you convert from Bitcoin to, for example, USDC? I cannot see any reference but I have this feature on the app. I wonder if API supports (or expects support for) this operation, or it just that I'm missing something.
Looking at the Coinbase API PRO Documentation you can create a conversion by:
HTTP REQUEST
POST /conversions
API KEY PERMISSIONS
This endpoint requires the “trade” permission.
Request
{
"from": "USD",
"to": "USDC",
"amount": "10000.00"}
PARAMETERS
from: A valid currency id
to: A valid currency id
amount: Amount of from to convert to to
Probably more of a question of what the valid currencies are
There is a reference for this in the Coinbase API documentation:
https://developers.coinbase.com/api/v2#transfer-money-between-accounts
But as I stated in my question, it unfortunately doesn't seem to work:
Coinbase transfer between accounts returns "Not found"
Without using CoinbasePro API but only Coinbase API from webapp that are the endpoints you need to call:
Have to know base_id of crypto that you want to sell and base_id of
crypto want to buy. You can know it by call GET
"https://api.coinbase.com/v2/
/assets/prices?base=USD&filter=holdable&resolution=latest" and get
from response the "base_id" of your currencies.
Make an order by calling POST "https://api.coinbase.com/v2/trade"
with a request body in json like this:
{ 'amount': [amount that you want to convert], 'amount_asset':
[currency of amount that you want to convert], 'amount_from':
'input', 'source_asset': ["base_id" of crypto that you want to
sell], 'target_asset': ["base_id" of crypto that you want to buy] }
If previous POST "/trade" response code is 201, you have to get the
"id" value of response's json and do a commit of your order by
calling POST "https://api.coinbase.com/v2/trades/[id of json
response of previous https://api.coinbase.com/v2/trade POST"]/commit". If
the response code of this POST commit is 201, your exchange is
started and if there are not error in coinbase, your conversion is
done!

How to set mail address for Unified Group in Microsoft Graph?

Currently I'm having a Microsoft Tenant with multiple domains assigned to it.
When I create a group I cannot specify the to be used domain. If I try by setting the mail property to a valid value {mailNickName}#{domainAvailable} the api returns an error:
Code: Request_BadRequest
Message: Property 'mail' is read-only and cannot be set.
So how can I define which domain of a tenant should be used when creating a unified group through Microsoft Graph API?
The mail property is generated automatically. In order to populate it, you need to flip the mailEnabled bit:
PATCH https://graph.microsoft.com/v1.0/groups/{id}
Content-type: application/json
{
"mailEnabled": true
}
The mail property will then be automatically populated by Exchange Online using mailNickname#default.domain.
I don't see the behavior Marc describes. I have two domains in 365:
example.com (default)
example.onmicrosoft.com
When I create a group with mailEnabled set to true and provide a nickname, I get something like the following:
{
"displayName": "Test Group",
"groupTypes": ["Unified"],
"mail": "test-group#example.onmicrosoft.com",
"mailNickname": "test-group",
"proxyAddresses": ["SMTP:test-group#example.onmicrosoft.com"],
"securityEnabled": false,
}

Change Recipient Address Google Apps Script

Is it possible to change the recipient address when using the reply function in Google Apps Script?
I want to receive an email from a random email account, mark it with a label and when scheduled, run the following code to reply to a desired email address rather than the original sender. The reason I want to reply is to keep it in the same thread. I have tried nearly all variations of the following code and can't get it to work the way I want it to:
thread.reply("This is a message.", {
htmlBody: "This is a message.",
name: "My Name",
recipient: "DESIRED#EMAIL.com",
replyTo: "DESIRED#EMAIL.com",
to: "DESIRED#EMAIL.com"
});
If you're asking to generate a random email address and send a real email from that address... that's not possible.
However... you could set the replyTo optional parameter as a random address - though when users would try to reply to that thread they would get a bounce-back notification that the address could not be reached. However, the original sender (the non-random address) would still be visible in the original message.
If you look at the GmailApp docs (replying)/(sending), you'll notice a few limitations. The sender's address (from) must be a valid Alias, if you're sending mail from MailApp (Google Apps Script).
However, there are plenty of methods in the GmailMessage class such as getFrom() and getReplyTo() that would allow you to get/set the message's from/replyTo parameters and have them be the same value. That way, when you reply to a message you will always be in the same thread.

Target email address validiation

Before the client sends a new email, he/she specifies one or more (To) destination addresses. Is there any way to check the validity of these emails before sending the message ?
Define "validity".
This JavaMail FAQ entry might help.
The InternetAddress class only checks the syntax of the address. The InternetAddress class is not able to determine whether the address actually exists as a legal address. It is not even possible to verify the host name if the application is running behind a firewall or isn't currently connected to the Internet.

Resources