OneDrive / onedrive-sdk-python

OneDrive SDK for Python! https://dev.onedrive.com
MIT License
1.08k stars 189 forks source link

OSError: [Errno 98] Address already in use #179

Closed ashish453 closed 4 years ago

ashish453 commented 4 years ago

I am using Google Colab. I installed onedrive-sdk-python by doing:

pip install https://github.com/OneDrive/onedrive-sdk-python/archive/master.zip And this is my authentication code:

import onedrivesdk
from onedrivesdk.helpers import GetAuthCodeServer
from onedrivesdk.helpers.resource_discovery import ResourceDiscoveryRequest

redirect_uri = 'http://localhost:8080'
client_id = "my client id"
client_secret = "my client secret"
discovery_uri = 'api.office.com/discovery'
auth_server_url = 'login.microsoftonline.com/common/oauth2/authorize'
auth_token_url = 'login.microsoftonline.com/common/oauth2/token'

http = onedrivesdk.HttpProvider()
auth = onedrivesdk.AuthProvider(http, client_id,
                                auth_server_url=auth_server_url,
                                auth_token_url=auth_token_url)
auth_url = auth.get_auth_url(redirect_uri)
code = GetAuthCodeServer.get_auth_code(auth_url, redirect_uri)
auth.authenticate(code, redirect_uri, client_secret, resource=discovery_uri)

And I got this error:


OSError Traceback (most recent call last)
in
code = GetAuthCodeServer.get_auth_code(auth_url, redirect_uri)

/usr/lib/python3.6/socketserver.py in server_bind(self)
self.socket.bind(self.server_address)

OSError: [Errno 98] Address already in use`
KTibow commented 4 years ago

What OS are you running on? First, if you're on Linux/Mac, sometimes running as root fixes this. What this means is that this was supposed to be for port 8080, but an application is already using that port. By the way, here's some better formatting for your issue: I am using Google Colab. I installed onedrive-sdk-python by doing:

pip install https://github.com/OneDrive/onedrive-sdk-python/archive/master.zip

And this is my authentication code:

import onedrivesdk
from onedrivesdk.helpers import GetAuthCodeServer
from onedrivesdk.helpers.resource_discovery import ResourceDiscoveryRequest

redirect_uri = 'http://localhost:8080'
client_id = "my client id"
client_secret = "my client secret"
discovery_uri = 'api.office.com/discovery'
auth_server_url = 'login.microsoftonline.com/common/oauth2/authorize'
auth_token_url = 'login.microsoftonline.com/common/oauth2/token'

http = onedrivesdk.HttpProvider()
auth = onedrivesdk.AuthProvider(http, client_id,
                                auth_server_url=auth_server_url,
                                auth_token_url=auth_token_url)
auth_url = auth.get_auth_url(redirect_uri)
code = GetAuthCodeServer.get_auth_code(auth_url, redirect_uri)
auth.authenticate(code, redirect_uri, client_secret, resource=discovery_uri)

And I got this error:

OSError Traceback (most recent call last)
in
code = GetAuthCodeServer.get_auth_code(auth_url, redirect_uri)

/usr/lib/python3.6/socketserver.py in server_bind(self)
self.socket.bind(self.server_address)

OSError: [Errno 98] Address already in use`
Ashish45351 commented 4 years ago

So how to solve it?

KTibow commented 4 years ago

@Ashish45351 Is this your second account? Anyway, try running it as admin/root/sudo. Also try rebooting.

KTibow commented 4 years ago

@ashish453 @Ashish45351 Can you close this? It clutters up everything.