I read this tutorial to implement twitter oauth in nodejs (for "login with twitter" purpose) -
http://codetheory.in/how-to-use-twitter-oauth-with-node-oauth-in-your-node-js-express-application/
The last piece of code has this variable called results which is supposed to hold the user data sent back by twitter, but for me it only contains screen_name and user_id which is not enough. I need much more data like profile image, etc.
So I looked at the twitter documentation -
https://dev.twitter.com/docs/api/1/get/users/show
The sample URL seems to work fine -
https://api.twitter.com/1/users/show.json?screen_name=TwitterAPI&include_entities=true
But recently I read twitter will shut down API 1 soon and replace it with API 1.1
So I tried the 1.1 API -
https://dev.twitter.com/docs/api/1.1/get/users/show
The sample URL does not work -
https://api.twitter.com/1.1/users/show.json?screen_name=rsarver
Gives error -
{"errors":[{"message":"Bad Authentication data","code":215}]}
What am I doing wrong ? How do I get user info properly from twitter and hopefully in my Node.js code that uses this module - https://github.com/ciaranj/node-oauth ?
Thanks in advance!
API v1.1 endpoints require OAuth authentication.
You might look at a different oauth module: ntwitter
Related
I can see the Service Account usage out of gcloud CLI by doing as such:
gcloud policy-intelligence query-activity --activity-type=serviceAccountKeyLastAuthentication --project=<project_name>
I would like to replicate this in a python script..
I am attempting to this do this but I am not sure how to authenticate, and I am getting a 401 error, despite having enabled the API. I am following this documentation. https://cloud.google.com/policy-intelligence/docs/activity-analyzer-service-account-authentication#iam-get-service-account-key-id-rest
import requests
r = requests.get(f"https://policyanalyzer.googleapis.com/v1/projects/{self.project_id}/locations/global/activityTypes/serviceAccountKeyLastAuthentication/activities:query?filter=activities.full_resource_name%3D%22%2F%2Fiam.googleapis.com%2Fprojects%2F{self.project_id}%2FserviceAccounts%2F{self.sa_email}%2Fkeys%2F{self.key_id}%22"
Is there some way I need to authenticate my request call? The rest of the script I am using the python client libraries using discovery.build and authenticating as such:
credentials, project = google.auth.default()
self.crm = discovery.build("cloudresourcemanager", "v3", credentials=credentials)
There does not seem to be a "policy analyzer" python library, so I am not sure on next steps.
The end goal is to see the last key authentication time of every service account key in the organization.
Thanks!
You may check this link for the sample Python code
Do note that the feature is still in preview and does not have a Python client for the same yet. The gcloud cli and REST is the way of accessing this feature programmatically.
Take a look at the python example shown towards the bottom of the page here:
https://cloud.google.com/iam/docs/reference/rest/v1/projects.serviceAccounts.keys/list
It shows how to get application default credentials used to pass in the client. You could accomplish the same with http requests, but that example above should help.
Also, looking at the original curl request, if you decode the filter to unicode it should be:
activities.full_resource_name="//iam.googleapis.com/projects/PROJECT_ID/serviceAccounts/SERVICE_ACCOUNT_EMAIL/keys/KEY_ID"
Assuming you got it from the sample [curl][1] request.
[1]: https://cloud.google.com/policy-intelligence/docs/activity-analyzer-service-account-authentication#view-recent-specific-key
I am working with the Evernote Python SDK, and proceeding through the Oauth workflow description here.
http://dev.evernote.com/doc/articles/authentication.php
How do I get a oauth_token_secret? I have my consumer secret, but don't see how to get the oauth_token_secret.
To retrieve an access token, I believe I will need to use the "get_access_token" function. One of the required arguments there is the oauth_token_secret.
https://github.com/evernote/evernote-sdk-python/blob/master/lib/evernote/api/client.py
I have the other pieces required (oauth_token, oauth_verifier).
I think you can leave that blank.
https://discussion.evernote.com/topic/18710-access-token-secret-returning-blank/
I am trying to get myself mediafeeds information with the following API (using JInstagram library):
https://api.instagram.com/v1/users/self/feed?access_token={valid access_token}
The response code is 404. I am not sure what I'm missing since the access_token is valid, the API is listed in the Ruby library, but it can't be found on the develop website.
I see there is a 404 error in this site for feeds to, but it are not same API.
Instagram changed their policy and also deprecated some APIs. Check the below link.
https://instagram.com/developer/changelog/
Old API
https://api.instagram.com/v1/users/self/feed?access_token={valid access_token}
Use the below API instead of the above one
https://api.instagram.com/v1/users/self/media/recent/?access_token=ACCESS-TOKEN
I'm using Allauth for Twitter, works like a charm.
I have never worked with Scopes, so my question is, is there any support to get for example the twitter user stream?
Or anyone got any ideas how to get the request working?
I'm struggeling with the twitter api, it seems way more complicated then facebook or foursquare or any other api i have come across.
with facebook it's like this
return requests.get("https://graph.facebook.com/v2.3/%s&access_token=%s" % (path, access_token)).json()
Now if i send
requests.get('https://api.twitter.com/1.1/statuses/home_timeline.json&oauth_consumer_key=' +oauth_con+ 'oauth_signature_method="HMAC-SHA1"&oauth_nonce="'+now+'"&oauth_token="'+twitter+'"&oauth_timestamp="'+now+'"&oauth_version=1.1"')
I get a either a 400 error or a 404 error depending on .json? or json&.
According to the doc you have to have "" around every parameter. Didn't help.
I have a requirement (flexible) to use oauth2. (existing architecture/code)
I have a need to do some text manipulation of subscriber's email headers.
Solutions I've tried.
I've tried to download the sample code for java and it correctly connects to gmail's imap servers. It however responds with oath_version=1 and is expecting a password. I've tried to massage the code to change the params as other api's like their Contacts api oauth2 without success.
Question:
(multipart)
Api is down:http://code.google.com/googleapps/domain/email_migration/developers_guide_java.html any reference online would be ideal (it has been down for at least half a week since last week Wed). If you wondered - yes I did post on their forums before asking here for the updated link.
Is there a way to: a) make oauth2 request and b) Any (minimal) code exaples I can look at would be great.
Thanks in advance for reading this post.
Here is a working, Ruby example of fetching email from Google using the OAuth2 protocol:
imap = Net::IMAP.new('imap.gmail.com', 993, usessl = true, certs = nil, verify = false)
imap.authenticate('XOAUTH2', 'example#gmail.com', 'oauth2_access_token_goes_here')
imap.select('INBOX')
imap.search(['ALL']).each do |message_id|
msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']
mail = Mail.read_from_string msg
puts mail.subject
puts mail.text_part.body.to_s
puts mail.html_part.body.to_s
end
Note: This example uses ruby mail gem and gmail_xoauth gem, so you will need those installed for this code sample to work. I am also using the omniauth and omniauth-google-oauth2 gems to handle logging the user in and using the access token.