내 Android 애플리케이션이 자바 OAuth 라이브러리를 사용하며 Twitter에서 승인을 위해 here을 발견했습니다. 요청 토큰을 받고 토큰을 인증하고 승인을 얻을 수 있지만 브라우저가 응용 프로그램과 다시 연결하기 위해 콜백 URL을 시도하면 코드에서 제공하는 URL을 사용하지 않지만 등록하는 동안 제공된 URL을 사용합니다 트위터와 함께.Android에서 OAuth + Twitter : 콜백 실패
참고 :
1. 내 애플리케이션을 트위터에 등록 할 때 나는 가상의 콜백 URL (http://abz.xyc.com)을 제공하고 브라우저로 애플리케이션 유형을 설정했습니다.
2. 코드 "myapp"에 콜백 URL을 제공하고 Browable 범주 및 데이터 체계가 "myapp"인 활동에 대한 의도 필터를 추가했습니다.
3. 권한 부여시 호출되는 URL에 코드에 지정된 te 콜백 URL이 포함되어 있습니다.
내가 여기 잘못 생각한가요?
관련 코드 : 올바른 일을하고있는 트위터는 항상 등록 된 콜백 URL을 수용 의해 나사처럼
public class FirstActivity extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
OAuthAccessor client = defaultClient();
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(client.consumer.serviceProvider.userAuthorizationURL + "?oauth_token="
+ client.requestToken + "&oauth_callback=" + client.consumer.callbackURL));
startActivity(i);
}
OAuthServiceProvider defaultProvider()
{
return new OAuthServiceProvider(GeneralRuntimeConstants.request_token_URL,
GeneralRuntimeConstants.authorize_url, GeneralRuntimeConstants.access_token_url);
}
OAuthAccessor defaultClient()
{
String callbackUrl = "myapp:///";
OAuthServiceProvider provider = defaultProvider();
OAuthConsumer consumer = new OAuthConsumer(callbackUrl,
GeneralRuntimeConstants.consumer_key, GeneralRuntimeConstants.consumer_secret,
provider);
OAuthAccessor accessor = new OAuthAccessor(consumer);
OAuthClient client = new OAuthClient(new HttpClient4());
try
{
client.getRequestToken(accessor);
} catch (Exception e)
{
e.printStackTrace();
}
return accessor;
}
@Override
protected void onResume()
{
// TODO Auto-generated method stub
super.onResume();
Uri uri = this.getIntent().getData();
if (uri != null)
{
String access_token = uri.getQueryParameter("oauth_token");
}
}
}
// Manifest file
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".FirstActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp"/>
</intent-filter>
</activity>
</application>
답장을 보내 주셔서 감사합니다. 1. 진술에 대한 참조를 인용 할 수 있습니까? "Twitter는 OAuth 요청에서 요청 된 콜백을 따르지 않으며 응용 프로그램 설정에 지정된 콜백 URL로 리디렉션됩니다 ("localhost "는 허용되지 않음).이에 따라 " 2. 네, 나는에 OAuth 콜백 - 온 - 안드로이드 질문을 확인했고 (예 : 브라우저) 내 응용 프로그램 유형을 설정했습니다. 다시 한 번 감사드립니다. 트위터 API에 – Samuh
추가 링크를 발표합니다. –
콜백의 OAuth에서 요구하는 경우 요청이 존중되지 않는 경우 내 애플리케이션을 다시 게시 승인으로 부르는 방법은 무엇입니까? 트위터는 Android 스타일의 URL을 수락하지 않으며이를 재정의해야합니다. 위의 경우 작동하지 않으면 대체 방법은 무엇입니까 도와주세요 .[10 당신이이 마지막 질문에 답한 후에 125 점 : – Samuh