-
Notifications
You must be signed in to change notification settings - Fork 186
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
authentication on raspberry pi #8
Comments
Hello Thomas, The
A caution on step (4): the default implementation of the Let me know if you have any questions! I'm glad to hear someone is using the API on a Raspberry Pi. I'd love to see whatever you end up making! Code for Step (1): import onedrivesdk
from onedrivesdk.helpers import GetAuthCodeServer
if __name__ == "__main__":
client_id = "{your_client_id}"
redirect_uri = "http://localhost:8080/"
client = onedrivesdk.get_default_client(client_id=client_id,
scopes=['onedrive.readwrite',
'wl.signin',
'wl.offline_access'])
auth_url = client.auth_provider.get_auth_url(redirect_uri)
# Block thread until we have the code
code = GetAuthCodeServer.get_auth_code(auth_url, redirect_uri)
print("Token available as 'code' local var, and here:\n")
print(code) |
PS the |
So complete newbie here... Messing with an RPi and simply wish to upload a few files via Python script. I was able to get some of the above working, howeer, it seems that when I issue the 'code = client.auth_provider...' command in my script, it fires up my default browser on the RPi (Epiphany) and shows me the code embedded in the URL, but then freezed execution of my script there. If I am quick enough, I can copy/paste the code from the URL, hardcode this into my 'code' value and can then successfully authenticate. If I could just figure out how to get the 'code = client.auth_provider...' to execute and continue with my script, I would be good to go. Any ideas? Perhaps I need a more complete example. |
Thanks for your reply... |
How did you create your client? Did you use the extension method |
Kevin, I would not recommend that you use the Like I recommended to Thomas, I would say you should get your auth code any way you feel comfortable, then make sure to save your first session. From there you can just keep refreshing your token and never need to get an auth code again. |
Yes, i use the method
|
I stand corrected. It does appear to be a Python 2 issue. I have identified the fix, which I'll bring in soon. Until then, can you make this small change and see if it works? Open the following file: @staticmethod
def load_session(**load_session_kwargs): Please try that again and let me know if it works or not. It worked for me. |
Now it works! When will you provide the new python package? |
Getting authentication access from onedrive without browser interaction can be done with Web driver phantomjs and Selenium. This allows to paring HTML response page from one page and authenticate, programmatically. This allows no user input like type username, password and give authorization. To install phantomjs webdriver (for headlness node) on raspberry pi please google it. author = 'Mariya' #Onedrive Access code from control panel #replace this value from your one drive developer panel. user_name = 'email_adress' client = onedrivesdk.get_default_client(client_id=client_id_str, """ driver.get(auth_url) login_field = driver.find_element_by_name("loginfmt") Fill user name and passwordlogin_field.send_keys(user_name) parse URL to get code and close the browsertokens = driver.current_url.split('=') print(tokens[1].split('&')[0])access_code = tokens[1].split('&')[0] |
This is definitely interesting. It basically pretends to be a web browser and submits the form. It's fragile, but then anything like this will tend to be fragile. If you submit a pull request with this code we can work on getting it merged into the main package! I would start with a new file in the /helpers directory. Perhaps |
Hi Chris, I written this method for Raspberry PI project to capture picture/Video (surveillance as just outdoor view) when motion detected and upload to One Drive 24/7. Since Raspberry PI not connected with any monitor so has to crack the website OR workaround this way. I am just curious!, is there any other or future plan to allow authentication without browser UI ? |
I want to use the new onedrive-sdk with my raspberry pi running raspbian, but i have problems to acquire the authentication code.
As we can see in the source code the authenticater uses the
webbrowser.open
command to get the authentication code, so i tried to install Lynx to get this command working,But each time my program calls
GetAuthCodeServer.get_auth_code(auth_url, redirect_uri)
, the following error is printed to the console:Error opening terminal: emacs Error opening terminal: emacs.
Is it even possible to authenticate without a graphical browser?
Best Regards,
Thomas
The text was updated successfully, but these errors were encountered: