Get Authorization Code From Callback Query - python

I'm currently working with the Spotify API. To work with it, I need to get the user to authorise and give permission for me to use their account data. After the user provides this permission, they are redirected to the Spotify homepage. In the URL of the homepage, they are taken to two query parameters including an authorisation code like so: https://open.spotify.com/?code=AQAKS1CbcTdK3...7JSQ.
How do I now get this code from the URL? I'm very new to this kind of programming so, if there is something I explained poorly, this is the link to where I got this info: https://developer.spotify.com/documentation/general/guides/authorization/code-flow/
Thanks so much to anyone who can help :)

Related

How do I tweet from my bot account when the bot app is created under a separate account?

I'm quite a novice, so please excuse my ignorance.
I've created a developer account on my personal Twitter account and my end goal is to have another account occasionally tweet something. I'm using tweepy and have successfully managed to tweet something, albeit from my account.
Twitter developer accounts can get their API key and secret, as well as an Access key and secret. What I'm trying to figure out is how to get my bot account's keys to have it tweet instead of my account.
After reading countless pages online as well as the docs, there seems to be a way to get auth another user through three-legged auth and pin-based auth, which seems like the correct route to my goal.
However, I have no idea where to go from here. The three-legged auth page asks for various required fields, of which I have no idea what to fill with (Callback URLs and Website URL). Moreover, the docs describe the process as one that needs to be initiated by the dev account, and I have no idea how to initiate that process at all.
Any help or guidance on what to do? My tweepy script is fully finished and just needs to be hooked up to the Twitter API.
Thanks.
EDIT & SOLUTION (03/18/2021):
Thanks to the comment by Sim leading to the article, I was able to derive a python script using Tweepy to authorize the bot using pin-based auth, found here. I'd give the article a read regardless, but once it starts telling you to create .js and .json files, stop there and use my script. That's what worked for me.
Found a solution that worked for me, I think this is what you need. https://dev.to/stratospher/many-bot-accounts-using-1-twitter-developer-account-17ff

How do I make Python urlib2 to cleverly avoid the security check while trying to log into a site?

I am trying to crawl a website for the first time. I am using urllib2 Python
I am currently trying to log into Foursquare social networking site using Python urlib2 and Beautifulsoup. To view a particular page, I need to provide username and password.
So,I followed the Basic Authentication described on the ducumentation page.
I guess, everything worked well, but the site throws up a security check asking me to type a text (capcha), before sending me the required page. It obviously looks like, the site is detecting that, a page is being requested not by a human, but a crawler.
So, what is the way, to avoid being detected. How to make urllib2 get the desired page, without having to stop at the security check? Pls help..
You probably want to use foursquare API instead.
You have to use the foursquare API. I guess, there is no other way. API are designed for such purposes.
Crawlers depending solely on the HTML format of the page will fail in the furture when the HTML page changes

Twitter Search API authentication

I had an application running on GAE which accessed twitter Search API. However recently twitter has moved to the new version 1.1 and previous version of api is no longer functional. And I'm having trouble accessing the new API.
Basically I wanted to get tweets matching a search query and I simply accessed the url using python code and got all the data in json format. The url I accessed (which is not working now) is:
http://search.twitter.com/search.json?q=query
Instead I searched and found out that the equivalent url in new API is probably:
https://api.twitter.com/1.1/search/tweets.json?q=query
However if I just access it simply like I did before (just fetching the url and accessing the contents) then it gives an error and apparently I need to authenticate my request by obtaining some oauth credentials and using them with the request.
I tried searching of how to do that if there is another method beside just fetcihng the url contents, but in vain. I'd really appreciate if someone could help me out, and if possible give some sample python code. Thanks!
New Twitter API needs user authentication, meaning that each user visiting your site will need to go through auth procedure. This makes new Twitter API much less useable.
See this answer for details how to use OAuth on GAE/Python.

How can i login to stackoverflow site with Scrapy python

I have just started learning scrapy and i want to try some prasing with python and Scrapy.
I am thinking of getting the list of questions from specific tags, which i have posted, and then parse them on SO.
But i am not sure how can i log with open id and Scrapy.
Can some please guide me with this on which url i have to submit the data because when i will type the openid then site gets transfered to openid url so how can i enter password there
Use your RSS feed (basically xml).
One other way I can think of is to:
Login normally in browser
export cookies to file
use that file in script
I can think of a situation where fanatic badge would become less valued. Because, then people would simply schedule cron on their server to visit SO every day! So, I advice not doing anything of this sort.
Here is a good example how to simulate a user login request using scrapy.

Facebook Permission request form for Crawling?

I have been Googling for sometime but I guess I am using the wrong set of keywords. Does anyone know this URI that lets me request permission from Facebook to let me crawl their network? Last time I was using Python to do this, someone suggested that I look at it but I couldn't find that post either.
Amazingly enough, that's given in their robots.txt.
The link you're looking for is this one:
http://www.facebook.com/apps/site_scraping_tos.php
If you're not a huge organization already, don't expect to be explicitly whitelisted there. If you're not explicitly whitelisted, you're not allowed to crawl at all, according to the robots.txt and the TOS. You must use the API instead.
Don't even think about pretending to be one of the whitelisted crawlers. Facebook filters by whitelisted IP for each crawler and anything else that looks at all like crawling gets an instant perma-ban. For a while users who simply clicked too fast could occasionally run into this.
Since this is a community with login & password, I am not sure how much of it is legally crawl-able. If you see even Google indexes just the user profile pages. But not their wall posts or photos etc.
I would suggest you to post this question in Facebook Forum. But you can check it up here -
Facebook Developers
Facebook Developers Documentation
Facebook Developers Forum

Categories