Changeset 21054 for lang/actionscript

Show
Ignore:
Timestamp:
10/09/08 19:36:55 (8 weeks ago)
Author:
lyokato
Message:

lang/actionscript/as3oauth: fixed some methods

Location:
lang/actionscript/as3oauth/src/org/coderepos/oauth
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/actionscript/as3oauth/src/org/coderepos/oauth/OAuthConsumer.as

    r17539 r21054  
    3737   *   myApp.saveRequestToken(requestToken); 
    3838   *   var authorizeURI:URI = new URI("http://example.org/authorize"); 
    39    *   authorizeURI.setQueryValue("token", requestToken.token); 
     39   *   authorizeURI.setQueryValue("oauth_token", requestToken.token); 
    4040   *   navigateToURL(authorizeURL); 
    4141   * } 
     
    4848   * consumer.addEventListener(OAuthEvent.GET_ACCESS_TOKEN_FAILED, onFailedToGetAccessToken); 
    4949   * var requestToken:OAuthToken = myApp.loadRequestToken(); 
    50    * consumer.getAccessToken(new URI("http://example.org/access_token"), requestToken); 
     50   * var option:OAuthRequestOption = new OAuthRequestOption(); 
     51   * option.token = requestToken; 
     52   * consumer.getAccessToken(new URI("http://example.org/access_token"), option); 
    5153   * 
    5254   * private function onCompletedToGetAccessToken(e:OAuthEvent):void { 
     
    448450      result.code = code; 
    449451      result.message = _lastResponse.message; 
    450       if (code == 200) { 
     452      if (code >= 200 && code < 300) { 
    451453        _lastResponseBody.position = 0; 
    452454        var response:ByteArray = new ByteArray(); 
     
    463465     * 
    464466     * @param uri request token uri 
    465      * @param realm optional 
     467     * @param option OAuthRequestOption object (optional) 
    466468     * @eventType org.coderepos.oauth.events.OAuthEvent.GET_REQUEST_TOKEN_COMPLETED 
    467469     * @eventType org.coderepos.oauth.events.OAuthEvent.GET_REQUEST_TOKEN_FAILED 
     
    469471     * @playerversion 9.0 
    470472     */ 
    471     public function getRequestToken(uri:URI, realm:String=null):void { 
     473    //public function getRequestToken(uri:URI, realm:String=null):void { 
     474    public function getRequestToken(uri:URI, option:OAuthRequestOption=null):void { 
    472475      if (_isFetching) return; 
    473476      clear(); 
    474477      initializeHttpClient(onCompletedToGetRequestToken); 
    475       var option:OAuthRequestOption = new OAuthRequestOption(); 
    476       option.realm = realm; 
     478      if (option == null) 
     479        option = new OAuthRequestOption(); 
    477480      sendRequest(uri, option); 
    478481    } 
     
    500503     * 
    501504     * @param uri request token uri 
    502      * @param token request token 
    503      * @param realm optional 
     505     * @param option OAuthRequestOption object 
    504506     * @eventType org.coderepos.oauth.events.OAuthEvent.GET_ACCESS_TOKEN_COMPLETED 
    505507     * @eventType org.coderepos.oauth.events.OAuthEvent.GET_ACCESS_TOKEN_FAILED 
     
    507509     * @playerversion 9.0 
    508510     */ 
    509     public function getAccessToken(uri:URI, token:OAuthToken, 
    510       realm:String=null):void { 
     511    public function getAccessToken(uri:URI, option:OAuthRequestOption):void 
     512    { 
    511513      if (_isFetching) return; 
     514      if (option.token == null) 
     515        throw new ArgumentError("getAccessToken: required request-token."); 
    512516      clear(); 
    513517      initializeHttpClient(onCompletedToGetAccessToken); 
    514       var option:OAuthRequestOption = new OAuthRequestOption(); 
    515       option.realm = realm; 
    516       option.token = token; 
    517518      sendRequest(uri, option); 
    518519    } 
  • lang/actionscript/as3oauth/src/org/coderepos/oauth/OAuthUtil.as

    r11511 r21054  
    144144 
    145145    /* 
    146      * parse HTTP WWW-Authentication header, and if it matches OAuth, 
     146     * parse HTTP WWW-Authenticate header, and if it matches OAuth, 
    147147     * gathers each parameters and returns them as an Object. 
    148148     *