Example #1
0
    def test_authorization_uri(self):
        from urlparse import urlparse
        from urlparse import parse_qsl
        from sanction.flow import AuthorizationRequestFlow

        f = AuthorizationRequestFlow(TestAdapterImpl(get_config()))

        uri = urlparse(f.authorization_uri())
        qs = dict(parse_qsl(uri.query))

        c = get_config()
        self.assertEquals(qs["scope"], c["testadapterimpl.scope"])
        self.assertEquals(qs["redirect_uri"], 
            c["testadapterimpl.redirect_uri"])
        self.assertEquals(qs["response_type"], "code")
        self.assertEquals(qs["client_id"], c["testadapterimpl.client_id"])
Example #2
0
    def parse_access_token(self, data):
        """ Parses the access token

        DeviantArt deviates (haha) from the :term:`OAuth2` spec by not passing
        back the "Bearer" token type, which is expected by sanction
        """
        data = AuthorizationRequestFlow.parse_access_token(self, data)
        data["token_type"] = "Bearer"
        return data
Example #3
0
    def authorization_uri(self, state=None):
        """ Google's authorization URI

        Google differs from the :term:`OAuth2` spec by appending the
        ``access_type`` request value through a URI query param.
        """
        uri = AuthorizationRequestFlow.authorization_uri(self, state)
        access_type = safe_get("access_type", self.adapter.config,
            required=True)
        return "%s&access_type=%s" % (uri, access_type)
Example #4
0
 def __init__(self, adapter):
     AuthorizationRequestFlow.__init__(self, adapter)