Giter Site home page Giter Site logo

pyshk's Introduction

Build Status Coverage Status Documentation Status

Pyshk is a python client for the mlkshk.com api.

Documentation is available at read the docs

Installation

Install via pypi:

pip install pyshk

In order to get started, you have to sign up for mlkshk (yay!) and create an application on mlkshk.com. First, you'll need to sign up for an account here: Create Account.

Then, create we'll create an application so that you can use the API. You should do that here. Give your application a title and a description. Make sure to fill in the "Redirect URL" cause we'll use that later. The redirect url has to be exactly the same on mlkshk.com and in your code or the server will return a 500 server error when you try to authenticate.

Once you click the big "Create It!" button, you'll be given a "Key" and a "Secret". Write those down. We'll need them later.

Usage

Start a python interpreter and then import the API:

from pyshk.api import Api

If you don't have an access token (you won't if this is the first run), start up the API using the Key and Secret from above:

a = Api(consumer_key=[Key], consumer_secret=[Secret])
a.get_auth(redirect_uri=[the redirect url from above])

At this point, your web browser will open and you'll be prompted to allow your application (whatever you named it) to access your account. Allow the app access and you'll be redirected to whatever redirect URL you specified when creating the app. The URL bar will have something like http://[redirect_url]?code=[code]. Copy and paste the [code] portion back into the python interpreter and hit enter. You'll then be given the access code and the access secret; you should write those down so you don't have to go through this again.

At this point, the API is authenticated and you can start making calls to the mlkshk server. If you went through this before and you already have an acces code & secret, you can pass those to the API when you instantiate it. Itl'll be something like:

api = Api(consumer_key='blah',
		  consumer_secret='blahsecretblah',
		  access_token_key='blah',
		  access_token_secret='blahsupersecretblah')

API Coverage:

Working resources:

  • GET /api/favorites
  • GET /api/favorites/after/(afterkey)
  • GET /api/favorites/before/(beforekey)

  • GET /api/friends
  • GET /api/friends/after/(afterkey)
  • GET /api/friends/before/(beforekey)

  • GET /api/incoming
  • GET /api/incoming/(id)/after/(afterkey)
  • GET /api/incoming/(id)/before/(beforekey)

  • GET /api/magicfiles
  • GET /api/magicfiles/(id)/after/(afterkey)
  • GET /api/magicfiles/(id)/before/(beforekey)

  • GET /api/shakes
  • GET /api/shakes/(id)
  • GET /api/shakes/(id)/after/(afterkey)
  • GET /api/shakes/(id)/before/(beforekey)

  • GET /api/sharedfile/(sharekey)
  • POST /api/sharedfile/(sharekey)
  • GET /api/sharedfile/(sharekey)/comments
  • POST /api/sharedfile/(sharekey)/comments
  • POST /api/sharedfile/(sharekey)/like
  • POST /api/sharedfile/(sharekey)/save

  • GET /api/user
  • GET /api/user_id/(user_id)
  • GET /api/user_name/(username)

  • POST /api/upload

Notes

  • POST /api/upload returns a 200 response, not 201 as stated in mlkshk docs.
  • GET /api/user_id/[x] & GET /api/user_name[x] for user x who does not exist raises a 500 Server Error, not 404 as in the API docs.

pyshk's People

Contributors

jeremylow avatar

Stargazers

 avatar  avatar

Watchers

 avatar

pyshk's Issues

SSL Verification Fails

https://mlkshk.com doesn't send the intermediate certificate causing requests.get or requests.post to fail. This is a server-side issue. Relevant files:

RapidSSL SHA256 CA - G3.txt

Output from console:

openssl s_client -CAfile /etc/ssl/certs/ca-certificates.crt -connect mlkshk.com:443
CONNECTED(00000003)
depth=0 OU = GT33610525, OU = See www.rapidssl.com/resources/cps (c)15, OU = Domain Control Validated - RapidSSL(R), CN = *.mlkshk.com
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 OU = GT33610525, OU = See www.rapidssl.com/resources/cps (c)15, OU = Domain Control Validated - RapidSSL(R), CN = *.mlkshk.com
verify error:num=21:unable to verify the first certificate
verify return:1

---
Certificate chain
 0 s:/OU=GT33610525/OU=See www.rapidssl.com/resources/cps (c)15/OU=Domain Control Validated - RapidSSL(R)/CN=*.mlkshk.com
   i:/C=US/O=GeoTrust Inc./CN=RapidSSL SHA256 CA - G3

---
Server certificate
-----BEGIN CERTIFICATE-----
MIIEqzCCA5OgAwIBAgIDAhvCMA0GCSqGSIb3DQEBCwUAMEcxCzAJBgNVBAYTAlVT
MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMSAwHgYDVQQDExdSYXBpZFNTTCBTSEEy
NTYgQ0EgLSBHMzAeFw0xNTAyMDMwMTQ4MjVaFw0xNjAzMDcxNTQwMzNaMIGQMRMw
EQYDVQQLEwpHVDMz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EBACnr4FnLJqmU28FfZzvNwufF
j+RlQfrVYLC8XN0GVTTg9/EdeRZb91LyQI42pJzKRW7SPmXMMl7qU3deoz67e6Hv
hSfTofM5Mo1x/znXffJpZQMKcF+4010j0ZyuaYcBfvB3aYpIpDpp/6QvcAmdxYj+
LLXqXVuUhN+0rI+K0E4+TW3qYZPEjeE1t9qMzefTsiFpnRMDEMXS4j289XrTuG8V
kWf/PYCP8hnavccqj+SiDoYuDwYy7JeFx+/JEFUuZ8EilKaLDKrKH9JWk/sUTZPv
E9gFXE9WdN295YhMgXBP3sWQ4XSYCGlcjm3oUvAVniz/yvOpMr+H7fJuNgAMWOM=
-----END CERTIFICATE-----
subject=/OU=GT33610525/OU=See www.rapidssl.com/resources/cps (c)15/OU=Domain Control Validated - RapidSSL(R)/CN=*.mlkshk.com
issuer=/C=US/O=GeoTrust Inc./CN=RapidSSL SHA256 CA - G3

---
No client certificate CA names sent
Peer signing digest: SHA512
Server Temp Key: ECDH, P-256, 256 bits

---
SSL handshake has read 1853 bytes and written 444 bytes

---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES128-GCM-SHA256
    Session-ID: AD146567EF08E082B36015B72C67B9220D0694A38176134D307474D62DC30796
    Session-ID-ctx: 
    Master-Key: B811162A113C1D8E389BFC65E778735FC1D9C3B90AA19366E0CA114FB9B37E0D31F0C7C67E7335D41DE51BE80BBE243D
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 300 (seconds)
    TLS session ticket:
    0000 - 00 8b fa 1f a1 c8 61 da-45 09 e6 32 4a 37 6d f9   ......a.E..2J7m.
    0010 - 8d d8 1c 2d ef 16 f8 62-46 09 37 3b 68 da 32 e6   ...-...bF.7;h.2.
    0020 - 19 4a 96 8b ef 85 9a a6-39 38 80 d4 7c 14 92 0b   .J......98..|...
    0030 - 6c 8c f7 91 01 5a 1a 74-16 03 37 b3 75 5a 82 4b   l....Z.t..7.uZ.K
    0040 - 35 af 57 a6 53 bf 74 84-51 12 5e 96 6c f2 65 54   5.W.S.t.Q.^.l.eT
    0050 - c9 7e f3 2e ea df c2 05-c6 74 f7 77 a7 b6 29 b9   .~.......t.w..).
    0060 - d3 3e 78 93 5e df 97 b1-48 13 7f 9e 72 3e 59 84   .>x.^...H...r>Y.
    0070 - 57 70 a8 e8 62 08 de e9-16 4d d6 31 10 e6 fc 18   Wp..b....M.1....
    0080 - d8 d3 ca 09 c0 8b c8 0a-4d 97 9a c6 7d 27 4e f6   ........M...}'N.
    0090 - d2 62 96 3b 3e 3c 10 bf-fb 08 2b e6 2b 9b c4 cf   .b.;><....+.+...

    Start Time: 1445426561
    Timeout   : 300 (sec)
    Verify return code: 21 (unable to verify the first certificate)

---

When providing the intermediate certificate, everything is fine:

openssl s_client -CAfile /home/jeremy/Desktop/RapidSSL\ SHA256\ CA\ -\ G3 -connect mlkshk.com:443
CONNECTED(00000003)
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify return:1
depth=1 C = US, O = GeoTrust Inc., CN = RapidSSL SHA256 CA - G3
verify return:1
depth=0 OU = GT33610525, OU = See www.rapidssl.com/resources/cps (c)15, OU = Domain Control Validated - RapidSSL(R), CN = *.mlkshk.com
verify return:1

---
Certificate chain
 0 s:/OU=GT33610525/OU=See www.rapidssl.com/resources/cps (c)15/OU=Domain Control Validated - RapidSSL(R)/CN=*.mlkshk.com
   i:/C=US/O=GeoTrust Inc./CN=RapidSSL SHA256 CA - G3

---
Server certificate
-----BEGIN CERTIFICATE-----
MIIEqzCCA5OgAwIBAgIDAhvCMA0GCSqGSIb3DQEBCwUAMEcxCzAJBgNVBAYTAlVT
MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMSAwHgYDVQQDExdSYXBpZFNTTCBTSEEy
NTY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NjAsMCoGCCsGAQUFBwIBFh5odHRwczovL3d3dy5yYXBpZHNz
bC5jb20vbGVnYWwwDQYJKoZIhvcNAQELBQADggEBACnr4FnLJqmU28FfZzvNwufF
j+RlQfrVYLC8XN0GVTTg9/EdeRZb91LyQI42pJzKRW7SPmXMMl7qU3deoz67e6Hv
hSfTofM5Mo1x/znXffJpZQMKcF+4010j0ZyuaYcBfvB3aYpIpDpp/6QvcAmdxYj+
LLXqXVuUhN+0rI+K0E4+TW3qYZPEjeE1t9qMzefTsiFpnRMDEMXS4j289XrTuG8V
kWf/PYCP8hnavccqj+SiDoYuDwYy7JeFx+/JEFUuZ8EilKaLDKrKH9JWk/sUTZPv
E9gFXE9WdN295YhMgXBP3sWQ4XSYCGlcjm3oUvAVniz/yvOpMr+H7fJuNgAMWOM=
-----END CERTIFICATE-----
subject=/OU=GT33610525/OU=See www.rapidssl.com/resources/cps (c)15/OU=Domain Control Validated - RapidSSL(R)/CN=*.mlkshk.com
issuer=/C=US/O=GeoTrust Inc./CN=RapidSSL SHA256 CA - G3

---
No client certificate CA names sent
Peer signing digest: SHA512
Server Temp Key: ECDH, P-256, 256 bits

---
SSL handshake has read 1853 bytes and written 444 bytes

---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES128-GCM-SHA256
    Session-ID: 9A2E434EB30D8481EA1E4C735FB7DDDFD55510F274E5CF4BEE35E18F4C6B90A9
    Session-ID-ctx: 
    Master-Key: 7A2DE1EFD37EF9C69C7B9D6CF6845CC2A4A8CA393DD9BD27180D2B3DE88D723FDFDEDD251D56CCE12946153DDD7A8FD8
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 300 (seconds)
    TLS session ticket:
    0000 - 00 8b fa 1f a1 c8 61 da-45 09 e6 32 4a 37 6d f9   ......a.E..2J7m.
    0010 - 93 c8 d1 e1 c2 ec 7c 0c-8f 97 8f 3e 07 bb a2 c3   ......|....>....
    0020 - 03 5e 94 fe df f6 2e 46-21 bf 84 53 86 47 3f d3   .^.....F!..S.G?.
    0030 - 86 36 0b 7e d7 04 cf 75-c2 ee b8 8f ee 74 24 fa   .6.~...u.....t$.
    0040 - f0 6d ed c9 07 06 32 2b-96 d0 88 af 75 aa 94 8b   .m....2+....u...
    0050 - 8f 6a 13 ab f6 ef a8 0f-2c 93 a0 35 13 76 d3 e8   .j......,..5.v..
    0060 - 7a 20 75 28 9f 0d 13 e3-05 12 ef 36 2d 1d d9 90   z u(.......6-...
    0070 - c3 da 95 d8 55 9a 88 83-0d 7b 4b b1 81 53 1c 67   ....U....{K..S.g
    0080 - 72 19 27 42 f4 a5 ff 03-d3 61 eb e7 94 38 12 dd   r.'B.....a...8..
    0090 - fa d6 1a a6 18 d9 c3 16-b2 3d 09 46 24 db 22 28   .........=.F$."(

    Start Time: 1445426673
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)

---

Cf. https://cryptoreport.websecurity.symantec.com/checker/#certChecker type in https://mlkshk.com and download missing cert. file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.