2013-04-20 94 views
0

我正在創建一個Windows 8地鐵應用程序,但我無法獲得oauth2訪問令牌。我可以用這個代碼就好獲得臨時代碼:在Windows應用程序中的Dwolla oauth訪問令牌

Uri requestUri = new Uri(string.Format(AUTH_URL + "?client_id={0}&response_type=code&scope={1}&client_secret={2}&redirect_uri={3}", CLIENT_ID, string.Join("|", scopeList.ToArray()), CLIENT_SECRET, WebAuthenticationBroker.GetCurrentApplicationCallbackUri().AbsoluteUri)); 
     WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, requestUri); 

但是當我嘗試使用代碼來獲得永久訪問令牌,它要麼給我一個內部服務器錯誤(500)或超時。它給了我500時,我沒有REDIRECT_URI,所以我把它放在我的,否則只是請求超時並使用此代碼沒有任何反應。

private const string TOKEN_URL = "https://www.dwolla.com/oauth/v2/token"; 
Uri requestUri = new Uri(string.Format(TOKEN_URL + "?client_id={0}&client_secret={1}&grant_type={2}&code={3}&redirect_uri={4}", CLIENT_ID, CLIENT_SECRET, GRANT_TYPE, code, WebAuthenticationBroker.GetCurrentApplicationCallbackUri().AbsoluteUri))); 
     WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.SilentMode, requestUri); 

我所有的字符串是URI轉義。我只是不知道我做錯了什麼。

使用任何除了WebAuthenticationOptions.SilentMode選項只是顯示加載瀏覽器窗口

也因爲他們使用.NetFramework而Windows 8應用程序使用.NetCore我不能使用爲C#做的OAuth庫,修剪down版本。

任何幫助將是巨大的

回答

1

requestUri看起來臨時代碼和重定向permananent訪問令牌之間的不同。它需要完全一樣的東西。