这是 API 文档。 http://developer.dribbble.com/v1/oauth/
这是客户端 ID:
客户ID
3acdea730eaae4ea51dadf296be4e8edf7cd4b6ab030ce69c1de0d1a335b679d
客户秘密
4a9773911cd2304fa23047e703e35fffbd443f32a9c73207aa60b45852e17b64
客户端访问令牌
57fe6dc09292e4dadce94a3dc9fd895117792a48f7194bbc5b8bd229e6ef1388
Java代码
String LOGIN_CALLBACK = "placeholder.com";
String LOGIN_URL = "https://dribbble.com/oauth/authorize?client_id="
+ "3acdea730eaae4ea51dadf296be4e8edf7cd4b6ab030ce69c1de0d1a335b679d"
+ "&redirect_uri=http%3A%2F%2F" + LOGIN_CALLBACK
+ "&scope=public+write+comment+upload";
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(LOGIN_URL)));
在清单中
<activity
android:name=".DribbbleLogin"
android:exported="true"
android:launchMode="singleTop">
<intent-filter>
<data
android:host="dribbble-auth-callback"
android:scheme="plain" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
回调 url 中应放置什么内容,重定向 url 中应传递什么内容,以便流程重定向到我的应用程序?
你的callbackUrl应该像
plain://example.com
一样,并且在android清单中还需要完成一件事
android:host="example.com"
android:scheme="plain"
只需输入callbackurl“plain://example.com”
在清单中
<activity
android:name=".DribbbleLogin"
android:exported="true"
android:launchMode="singleTop">
<intent-filter>
<data
android:host="example.com"
android:scheme="plain" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
在 DribbbleLogin 活动中
String loginCallback = "electedface.com";
String code;
Intent intent = getIntent();
if (intent != null
&& intent.getData() != null
&& !TextUtils.isEmpty(intent.getData().getAuthority())
&& loginCallback.equals(intent.getData().getAuthority())) {
code = intent.getData().getQueryParameter("code");
}
使用 dribbble_client_id、dribbble_client_secret 和此代码调用登录网址“https://dribbble.com//oauth/token”。您将获得 json 格式的 access_token、token_type、scope。
谢谢大家