我使用改裝打造的Android應用程序Github上,但我從https://api.github.com/authorizations改造-u用戶名:密碼字段和範圍陣列
我知道如何用命令捲曲的要求去做有麻煩檢索令牌:
curl -X POST -H "Accept: Application/json" -u "username:password" -d '{"scopes": ["user","repo","gist","notifications","repo","repo:status"],"note":"GithubViewer Android App","client_id":"xxx","client_secret":"yyyy"}' "https://api.github.com/authorizations"
我遇到了麻煩,知道如何設置Scopes數組和-u認證字段。我一直在使用「:基本用戶名:密碼驗證」在命令行中嘗試,但不工作,要麼:(
這裏是什麼,我試圖做一個樣本:
RequestInterceptor interceptor = new RequestInterceptor() {
@Override
public void intercept(RequestFacade request) {
request.addHeader("Authentication", "Basic " + username + ":" + password);
}
};
RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(GithubClient.API_URL)
.setRequestInterceptor(interceptor)
.build();
任何建議?
謝謝
你可以發佈你做了什麼嗎? – Atieh 2015-02-02 00:14:42
這就是我所做的。首先,我修改了我的請求,以發送帶請求的@Body。我創建了一個可以序列化爲該請求所需的類的類。 https://gist.github.com/fnk0/f3ef3d5d15d72bff3fb2 – 2015-02-02 19:57:19
我想通了昨天該怎麼做。我錯過了那裏的@Body註釋,不得不創建一個基本的認證。謝謝!你完成了你的應用程序?我可以查看它8D – Atieh 2015-02-02 20:12:37