def filter(self, filters): """ Search through the issues applying filters. Look at https://confluence.atlassian.com/display/BITBUCKET/Issues to get a complete list of possible filters. :var filters: A dictionary of filters. Keys are strings corresponding to the filter names and values are ether string filter values or tuples, in which case their conditions are implicitly ORed. For example, {"title": ("~one", "~two")} would mean issues with the title containing either "one" or "two" :vartype filters: dict of str to str or tuple of str """ # because http.Request needs params to be a dict of strings to strings # (roughly) and since BitBucket wants repeated parameters to express # OR, we'll do the quoting by hand ourselves def flatten_conditions(filters): for key, val in filters.items(): if isinstance(val, (list, tuple)): for v in val: yield (port.to_b(key), port.to_b(v)) else: yield (port.to_b(key), port.to_b(val)) to_encode = tuple(flatten_conditions(filters)) qs = port.urlencode(to_encode) url = '{0}/?{1}'.format(self.get_url(), qs) return http.Request('GET', url), parsers.parse_json
def urlencode_any(d): """ Encode a dictionary consisting of a mixture of bytes, text and integers into a str object that only uses ASCII characters. """ as_bytes = dict((port.to_b(key), port.to_b(value)) for key, value in d.items()) return port.urlencode(as_bytes)
def urlencode_any(d): """ Encode a dictionary consisting of a mixture of bytes, text and integers into a str object that only uses ASCII characters. """ as_bytes = dict( (port.to_b(key), port.to_b(value)) for key, value in d.items()) return port.urlencode(as_bytes)
def urlencode_any(d): """ Encode a dictionary or a sequence of two-element tuples consisting of a mixture of bytes, text and integers into a str object that only uses ASCII characters. """ try: d = d.items() except AttributeError: pass as_bytes = tuple((port.to_b(key), port.to_b(value)) for key, value in d) return port.urlencode(as_bytes)
def get_auth_url(self, response_type, redirect_uri, scope, state=None, access_type=None, approval_prompt=None, login_hint=None, openid_realm=None, hd=None): """ This endpoint is the target of the initial request for an access token. It handles active session lookup, authenticating the user, and user consent. The result of requests of this endpoint include access tokens, refresh tokens, and authorization codes. :var response_type: Determines if the Google OAuth 2.0 endpoint returns an authorization code. For installed applications, a value of code should be used. :vartype response_type: str :var redirect_uri: One of the redirect_uri values registered at the APIs Console. Determines where the response is sent. You may choose between urn:ietf:wg:oauth:2.0:oob or an http://localhost port. :vartype redirect_uri: str :var scope: Space delimited set of permissions the application requests. Indicates the Google API access your application is requesting. The values passed in this parameter inform the consent page shown to the user. There is an inverse relationship between the number of permissions requested and the likelihood of obtaining user consent. :vartype scope: str :var state: Indicates any state which may be useful to your application upon receipt of the response. The Google Authorization Server roundtrips this parameter, so your application receives the same value it sent. :vartype state: str :var access_type: online or offline. Indicates if your application needs to access a Google API when the user is not present at the browser. This parameter defaults to online. If your application needs to refresh access tokens when the user is not present at the browser, then use offline. This will result in your application obtaining a refresh token the first time your application exchanges an authorization code for a user. :vartype access_type: str :var approval_prompt: force or auto. Indicates if the user should be re-prompted for consent. The default is auto, so a given user should only see the consent page for a given set of scopes the first time through the sequence. If the value is force, then the user sees a consent page even if they have previously given consent to your application for a given set of scopes. :vartype approval_prompt: str :var login_hint: When your application knows which user it is trying to authenticate, it may provide this parameter as a hint to the Authentication Server. Passing this hint will either pre-fill the email box on the sign-in form or select the proper multi-login session, thereby simplifying the login flow. :vartype login_hint: str :var openid_realm: Parameter from the OpenID 2.0 protocol, not from OAuth 2.0. It is used in OpenID 2.0 requests to signify the URL-space for which an authentication request is valid. :vartype openid_realm: str :var hd: The hd (hosted domain) parameter streamlines the login process for Google Apps hosted accounts. By including the domain (for example, mycollege.edu), you restrict sign-in to accounts at that domain :vartype hd: str """ params = {'client_id': self.client_id} params.update( base.get_params(None, locals(), translate_param=handle_realm)) return '{0}?{1}'.format(self.get_url('auth'), urlencode(params))
def test_get_auth_url(self): auth_url = self.service.get_auth_url('code', 'foo', 'openid', openid_realm='bar') self.assertTrue(urlencode({'openid.realm': 'bar'}) in auth_url)
def get_auth_url(self, response_type, redirect_uri, scope, state=None, access_type=None, approval_prompt=None, login_hint=None, openid_realm=None): """ This endpoint is the target of the initial request for an access token. It handles active session lookup, authenticating the user, and user consent. The result of requests of this endpoint include access tokens, refresh tokens, and authorization codes. :var response_type: Determines if the Google OAuth 2.0 endpoint returns an authorization code. For installed applications, a value of code should be used. :vartype response_type: str :var redirect_uri: One of the redirect_uri values registered at the APIs Console. Determines where the response is sent. You may choose between urn:ietf:wg:oauth:2.0:oob or an http://localhost port. :vartype redirect_uri: str :var scope: Space delimited set of permissions the application requests. Indicates the Google API access your application is requesting. The values passed in this parameter inform the consent page shown to the user. There is an inverse relationship between the number of permissions requested and the likelihood of obtaining user consent. :vartype scope: str :var state: Indicates any state which may be useful to your application upon receipt of the response. The Google Authorization Server roundtrips this parameter, so your application receives the same value it sent. :vartype state: str :var access_type: online or offline. Indicates if your application needs to access a Google API when the user is not present at the browser. This parameter defaults to online. If your application needs to refresh access tokens when the user is not present at the browser, then use offline. This will result in your application obtaining a refresh token the first time your application exchanges an authorization code for a user. :vartype access_type: str :var approval_prompt: force or auto. Indicates if the user should be re-prompted for consent. The default is auto, so a given user should only see the consent page for a given set of scopes the first time through the sequence. If the value is force, then the user sees a consent page even if they have previously given consent to your application for a given set of scopes. :vartype approval_prompt: str :var login_hint: When your application knows which user it is trying to authenticate, it may provide this parameter as a hint to the Authentication Server. Passing this hint will either pre-fill the email box on the sign-in form or select the proper multi-login session, thereby simplifying the login flow. :vartype login_hint: str :var openid_realm: Parameter from the OpenID 2.0 protocol, not from OAuth 2.0. It is used in OpenID 2.0 requests to signify the URL-space for which an authentication request is valid. :vartype openid_realm: str """ params = {'client_id': self.client_id} params.update(base.get_params(None, locals(), translate_param=handle_realm)) return '{0}?{1}'.format(self.get_url('auth'), urlencode(params))