Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User level authentication #13

Open
rwa opened this issue Jan 26, 2018 · 3 comments
Open

User level authentication #13

rwa opened this issue Jan 26, 2018 · 3 comments

Comments

@rwa
Copy link

rwa commented Jan 26, 2018

It looks like this client doesn't support "user level authentication" as described in the smashrun docs. Is that right?

Do you think it would be straightforward to add it? If so I'll take a shot. I am not familiar with OAuth but I think I can figure it out as I go.

https://api.smashrun.com/v1/documentation

@campbellr
Copy link
Owner

Hi @rwa

I'd be happy to accept a pull request. Let me know if you have any questions.

The user-level authentication didn't exist when I first wrote this library.

Reading the docs, it does seem like it should be simple to add.

@magnific0
Copy link
Contributor

magnific0 commented Feb 26, 2018

Hi @rwa and @campbellr

I looked a bit into user level authentication (implicit flow) and it seems that the current library is already compatible, so I don't think a code change is actually necessary. This is a small example (Python 3)

#!/usr/bin/env python3
"""
Example script for usage of Python Smashrun Client
"""

from smashrun import Smashrun
from oauthlib.oauth2 import MobileApplicationClient

mobile = MobileApplicationClient('client') # implicit flow

# Set token for repeated usage, skipping implicit authentication flow
token = None

if not token:
    client = Smashrun(client_id='client',client=mobile,client_secret='my_secret',redirect_uri='https://httpbin.org/get')
    auth_url = client.get_auth_url()
    token = input("Go to '%s' and authorize this application. Copy the access_token from the browser address bar and paste here: " % auth_url[0])

client = Smashrun(client_id='client',client=mobile,token={'access_token':token,'token_type':'Bearer'})
print(client.get_current_weight())

I would be happy to add a MWE to the README of my current PR #14.

Let me know!

@rwa
Copy link
Author

rwa commented Feb 26, 2018

Cool. Yes that sounds very useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants