I tried to get the authentication code of Qiita API with Python.

A Python beginner tries to get a Qiita.com authentication token.

#!C:/Python27/
# -*- coding:utf-8 -*-
import urllib
import urllib2
import cookielib
import json
# http is urllib2.HTTPHandler(debuglevel=1)
opener = urllib2.build_opener(urllib2.HTTPSHandler(debuglevel=1),                                   urllib2.HTTPCookieProcessor(cookielib.CookieJar()))
urllib2.install_opener(opener) 

def get_token() :
    name = 'user_name'
    passwd = '**********'
    url = 'https://qiita.com/api/v1/auth'
    login_post = {'url_name':name,'password':passwd}
    param = urllib.urlencode(login_post)

    req = urllib2.Request(url,param)
    res = urllib2.urlopen(req)
    token = json.loads(res.read())
    return token['token']    

'

Recommended Posts

I tried to get the authentication code of Qiita API with Python.
I tried to get the movie information of TMDb API with Python
I tried to find the entropy of the image with python
I tried scraping the ranking of Qiita Advent Calendar with Python
I tried to improve the efficiency of daily work with Python
PhytoMine-I tried to get the genetic information of plants with Python
I tried to touch the API of ebay
I tried to get CloudWatch data with Python
I tried to get the number of days of the month holidays (Saturdays, Sundays, and holidays) with python
Get the number of articles accessed and likes with Qiita API + Python
I tried to streamline the standard role of new employees with Python
[First API] Try to get Qiita articles with Python
I tried to get started with blender python script_Part 01
I tried to touch the CSV file with Python
I tried to solve the soma cube with python
I tried to get started with blender python script_Part 02
I tried to verify the speaker identification by the Speaker Recognition API of Azure Cognitive Services with Python. # 1
I tried to verify the speaker identification by the Speaker Recognition API of Azure Cognitive Services with Python. # 2
I tried to solve the problem with Python Vol.1
[Python] I tried to get Json of squid ring 2
I tried hitting the API with echonest's python client
I tried to summarize the string operations of Python
I tried to easily visualize the tweets of JAWS DAYS 2017 with Python + ELK
I tried to refactor the code of Python beginner (junior high school student)
I tried to automatically send the literature of the new coronavirus to LINE with Python
I tried to get and analyze the statistical data of the new corona with Python: Data of Johns Hopkins University
I tried to refactor the template code posted in "Getting images from Flickr API with Python" (Part 2)
I tried "gamma correction" of the image with Python + OpenCV
I tried to simulate how the infection spreads with Python
I tried to get the location information of Odakyu Bus
[Python] I tried to visualize the follow relationship of Twitter
[Python] I tried collecting data using the API of wikipedia
I tried to divide the file into folders with Python
I tried to get various information from the codeforces API
Get the source of the page to load infinitely with python.
I tried to put out the frequent word ranking of LINE talk with Python
I tried to automate the article update of Livedoor blog with Python and selenium.
I tried to compare the processing speed with dplyr of R and pandas of Python
The 15th offline real-time I tried to solve the problem of how to write with python
I tried to explain how to get the article content with MediaWiki API in an easy-to-understand manner with examples (Python 3)
I tried to get started with Hy
I tried to touch the COTOHA API
[Python] Get the character code of the file
I tried to solve the ant book beginner's edition with python
Get the number of PVs of Qiita articles you posted with API
I tried to get the index of the list using the enumerate function
I tried to automate the watering of the planter with Raspberry Pi
[Python] A memo that I tried to get started with asyncio
I want to output the beginning of the next month with Python
Sample to use after OAuth authentication of BOX API with Python
I tried to create a list of prime numbers with python
I wrote the code to write the code of Brainf * ck in python
I tried to fix "I tried stochastic simulation of bingo game with Python"
I tried to get started with Bitcoin Systre on the weekend
I tried to expand the size of the logical volume with LVM
[Python] I tried to get various information using YouTube Data API!
I tried to automatically collect images of Kanna Hashimoto with Python! !!
I tried to automatically post to ChatWork at the time of deployment with fabric and ChatWork Api
How to write offline real time I tried to solve the problem of F02 with Python
I tried to create a Python script to get the value of a cell in Microsoft Excel
I wrote a doctest in "I tried to simulate the probability of a bingo game with Python"