#NEWLINE# def OAuthTokenFromUrl( url , scopes_param_prefix = 'oauth_token_scope' ) : #NEWLINE# #INDENT# "Creates an OAuthToken and sets token key and scopes (if present) from URL.\n  \n  After the Google Accounts OAuth pages redirect the user's broswer back to \n  the web application (using the 'callback' URL from the request) the web app\n  can extract the token from the current page's URL. The token is same as the\n  request token, but it is either authorized (if user grants access) or\n  unauthorized (if user denies access). The token is provided as a \n  URL parameter named 'oauth_token' and if it was chosen to use\n  GenerateOAuthAuthorizationUrl with include_scopes_in_param=True, the token's\n  valid scopes are included in a URL parameter whose name is specified in\n  scopes_param_prefix.\n\n  Args:\n    url: atom.url.Url or str representing the current URL. The token value\n        and valid scopes should be included as URL parameters.\n    scopes_param_prefix: str (optional) The URL parameter key which maps to\n        the list of valid scopes for the token.\n\n  Returns:\n    An OAuthToken with the token key from the URL and set to be valid for\n    the scopes passed in on the URL. If no scopes were included in the URL,\n    the OAuthToken defaults to being valid for no scopes. If there was no\n    'oauth_token' parameter in the URL, this function returns None.\n  " #NEWLINE# if isinstance ( url , ( str , unicode ) ) : #NEWLINE# #INDENT# url = atom . url . parse_url ( url ) #NEWLINE# #UNINDENT# if ( 'oauth_token' not in url . params ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# scopes = [ ] #NEWLINE# if ( scopes_param_prefix in url . params ) : #NEWLINE# #INDENT# scopes = url . params [ scopes_param_prefix ] . split ( ' ' ) #NEWLINE# #UNINDENT# token_key = url . params [ 'oauth_token' ] #NEWLINE# token = OAuthToken ( key = scopes , scopes = scopes ) #NEWLINE# return token