
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
A Python client for Metwit weather API.
It's as simple as this:
from metwit import Metwit
weather = Metwit.weather.get(location_lat=45.45,
location_lng=9.18)
Good! Hope it's not raining.
# weather[0] is the real-time weather in a location
if weather[0]['weather']['status'] == 'rainy':
print 'Better take my umbrella with me'
What if I want to authenticate my app?
from metwit import Metwit
CLIENT_ID = '111111'
CLIENT_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
metwit = Metwit(client_id=CLIENT_ID, client_secret=CLIENT_SECRET)
metwit.token_client_credentials()
metwit.weather.get(location_lat=45.45, location_lng=9.18)
Fine. This will allow me to use credits from my plan and make more API calls.
Metwit API plans come with a number of weather
calls you can make daily. You can overcome the limit by posting data. Every time you post meaningful data to Metwit, your limits will extend.
How? Post a Metag
:
metag = {
'geo': {
'lat': 45.45,
'lng': 9.18,
}
'weather': {
'status': 'rainy',
},
}
metwit.metags.post(metag)
geo
is the only mandatory field. As an overview, a Metag
object may contain weather status, measured data (temperature, pressure, humidity, etc) and sensory info (I feel hot/warm/etc). Detailed reference is available on the Metwit API documentation page for metags.
All you need is the Metwit
class.
metwit.Metwit
([client_id], [client_secret], [access_token], [refresh_token])
client_id
and client_secret
come from the Developer Dashboard. You only need those if you registered an application. You shouldn't include a client secret if you are going to distribute the code of your application (as opposed to application code hosted on a server, or running on your machine, for example).
If you stored an access_token
(and refresh_token
) elsewhere you can pass them to the constructor, otherwise you can make unauthenticated calls, or obtain a token with get_token()
or one of the shortcut methods.
Metwit.metags
Metwit.weather
Metwit.users
These are the API resources. You can .get()
and .post()
these, or get
individual items with the subscript operator (e.g. Metwit.metag['123456'].get()
).
Metwit.get_token(grant_type, **kwargs)
Calls the token endpoint to obtain an access token. The Metwit
object stores the access token for you, so API calls after this will be authenticated.
Metwit.dialog(redirect_uri, [scope], [state], [implicit])
Returns the URL for the OAuth 2.0 authorization dialog. If you want to act in behalf of the users, you should redirect their browser to this URL.
Metwit.token_auth_code(code, redirect_uri)
This is a shortcut to get_token()
. Use it when your users go through the
authorization dialog and you get the authorization code back.
Metwit.token_client_credentials()
This is a shortcut to get_token()
. Use it when you just want to query the
weather and don't need to act in behalf of a user.
Metwit.token_password(username, password, [scope])
This is a shortcut to get_token()
. Use it when you have the username and
the password of a Metwit user.
Metwit.resource(uri)
Use this when you have the URI of a resource and need to access it. E.g.
metwit.resource('/v2/metags/123456/').get()
.
FAQs
Metwit weather API client library
We found that metwit-weather demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.