2016-09-30 4 views
1

read, write Trello API에 대한 액세스 권한을 얻는 사용자를 인증하려고합니다. 나는 자동 작성을 위해 OAuth1Swift을 사용하고 있지만 권한을 추가하기 위해 매개 변수를 추가하거나 app name을 추가 할 수는 없습니다.OAuth1Swift를 사용하여 읽기 권한, 쓰기 권한으로 Trello API 사용자를 인증하는 방법

이 매개 변수를 어떻게 추가합니까? 이것은 아래 코드입니다.

OAuthSwift Library

모든 시도 후

Trello API Docs

func doOAuthTrello() { 
    let oauthswift = OAuth1Swift(
     consumerKey: "consumerKey", 
     consumerSecret: "consumerSecret", 
     requestTokenUrl: "https://trello.com/1/OAuthGetRequestToken", 
     authorizeUrl:  "https://trello.com/1/OAuthAuthorizeToken", 
     accessTokenUrl:  "https://trello.com/1/OAuthGetAccessToken" 
    ) 

    self.oauthswift = oauthswift 
    oauthswift.authorizeURLHandler = getURLHandler() 
    let _ = oauthswift.authorize(
     withCallbackURL: URL(string: "oauth-swift://oauth-callback/trello")!, 
     success: { credential, response, parameters in 
      self.showTokenAlert(name: serviceParameters["name"], credential: credential) 
      self.testTrello(oauthswift) 
     }, 
     failure: { error in 
      print(error.localizedDescription, terminator: "") 
     } 
    ) 
} 

답변

3

,이 솔루션입니다 :

lazy var paramaters:[String: String] = { 
    return [ 
     "consumerKey": "consumerKey", 
     "consumerSecret": "consumerSecret", 
     "requestTokenUrl": "https://trello.com/1/OAuthGetRequestToken?scope=read,write,account&expiration=never&name=AppName", 
     "authorizeUrl": "https://trello.com/1/OAuthAuthorizeToken?scope=read,write,account&expiration=never&name=AppName", 
     "accessTokenUrl": "https://trello.com/1/OAuthGetAccessToken?scope=read,write,account&expiration=never&name=AppName" 
    ] 
}() 

마법은 URL 매개 변수에 ?scope=read,write,account&expiration=never&name=AppName를 추가하여 발생