strava_map/stravauth/stravauth.py
def authorize(self, response_type='code',
                  scope='read,profile:read_all,activity:read_all',
                  approval_prompt='auto'
                  ):
        """Authorizes the Strava Client if there are no exisiting credentials.

        Args:
            response_type (str, optional): The response of the authorization
                request. Defaults to 'code'.
            scope (str, optional): The scope of what the app is allowed to
                access. Defaults to 'read,profile:read_all,activity:read_all'.
            approval_prompt (str, optional): Option to either force the user to
                acknowledge the request, or automaticaly pass through if the app
                is already authorized. Defaults to 'auto'.
        """
        
        if not (self.client_id or self.client_secret):
            self.client_id = int(input('Enter Client ID: '))
            self.client_secret = input('Enter Client Secret: ')
            
        self.oauth_params = {"client_id": self.client_id,
                             "response_type": response_type,
                             "redirect_uri": "http://localhost:8000/authorization_successful",
                             "scope": scope,
                             "approval_prompt": approval_prompt
                             }
        url = 'https://www.strava.com/oauth/authorize?' + urllib.parse.urlencode(self.oauth_params)
        webbrowser.get().open(url)
        success_url = urllib.parse.urlparse(input('Paste the Success URL here:')).query
        query = urllib.parse.parse_qs(success_url)
        self.code = query['code']
        self.token_params = {"client_id": self.client_id,
                        "client_secret": self.client_secret,
                        "code": self.code,
                        "grant_type": "authorization_code"
                        }
        self.r = requests.post("https://www.strava.com/oauth/token", self.token_params)

        self.write_creds()
Authorizes the Strava Client if there are no exisiting credentials.

        Args:
            response_type (str, optional): The response of the authorization
                request. Defaults to 'code'.
            scope (str, optional): The scope of what the app is allowed to
                access. Defaults to 'read,profile:read_all,activity:read_all'.
            approval_prompt (str, optional): Option to either force the user to
                acknowledge the request, or automaticaly pass through if the app
                is already authorized. Defaults to 'auto'.
        
Authorizes the Strava Client if there are no exisiting credentials.
Authorizes the Strava Client if there are no exisiting credentials .
def authorize(self, response_type='code',
                  scope='read,profile:read_all,activity:read_all',
                  approval_prompt='auto'
                  ):
        if not (self.client_id or self.client_secret):
            self.client_id = int(input('Enter Client ID: '))
            self.client_secret = input('Enter Client Secret: ')
        self.oauth_params = {"client_id": self.client_id,
                             "response_type": response_type,
                             "redirect_uri": "http://localhost:8000/authorization_successful",
                             "scope": scope,
                             "approval_prompt": approval_prompt
                             }
        url = 'https://www.strava.com/oauth/authorize?' + urllib.parse.urlencode(self.oauth_params)
        webbrowser.get().open(url)
        success_url = urllib.parse.urlparse(input('Paste the Success URL here:')).query
        query = urllib.parse.parse_qs(success_url)
        self.code = query['code']
        self.token_params = {"client_id": self.client_id,
                        "client_secret": self.client_secret,
                        "code": self.code,
                        "grant_type": "authorization_code"
                        }
        self.r = requests.post("https://www.strava.com/oauth/token", self.token_params)
        self.write_creds()
def authorize ( self , response_type = 'code' , scope = 'read,profile:read_all,activity:read_all' , approval_prompt = 'auto' ) : if not ( self . client_id or self . client_secret ) : self . client_id = int ( input ( 'Enter Client ID: ' ) ) self . client_secret = input ( 'Enter Client Secret: ' ) self . oauth_params = { "client_id" : self . client_id , "response_type" : response_type , "redirect_uri" : "http://localhost:8000/authorization_successful" , "scope" : scope , "approval_prompt" : approval_prompt } url = 'https://www.strava.com/oauth/authorize?' + urllib . parse . urlencode ( self . oauth_params ) webbrowser . get ( ) . open ( url ) success_url = urllib . parse . urlparse ( input ( 'Paste the Success URL here:' ) ) . query query = urllib . parse . parse_qs ( success_url ) self . code = query [ 'code' ] self . token_params = { "client_id" : self . client_id , "client_secret" : self . client_secret , "code" : self . code , "grant_type" : "authorization_code" } self . r = requests . post ( "https://www.strava.com/oauth/token" , self . token_params ) self . write_creds ( )
Authorizes the Strava Client if there are no exisiting credentials.
Authorizes the Strava Client if there are no exisiting credentials .
"""Authorizes the Strava Client if there are no exisiting credentials.

        Args:
            response_type (str, optional): The response of the authorization
                request. Defaults to 'code'.
            scope (str, optional): The scope of what the app is allowed to
                access. Defaults to 'read,profile:read_all,activity:read_all'.
            approval_prompt (str, optional): Option to either force the user to
                acknowledge the request, or automaticaly pass through if the app
                is already authorized. Defaults to 'auto'.
        """
self
response_type
The response of the authorization
request. Defaults to 'code'.
The response of the authorization request . Defaults to ' code ' .
scope
The scope of what the app is allowed to
access. Defaults to 'read,profile:read_all,activity:read_all'.
The scope of what the app is allowed to access . Defaults to ' read profile : read_all activity : read_all ' .
approval_prompt
Option to either force the user to
acknowledge the request, or automaticaly pass through if the app
is already authorized. Defaults to 'auto'.
Option to either force the user to acknowledge the request or automaticaly pass through if the app is already authorized . Defaults to ' auto ' .