How to get user ID and user display name via OAuth2 API on different sites.
https://www.googleapis.com/oauth2/v1/userinfo
Method: GET.
Arguments:
alt:json.access_token: Your OAuth2 Access Token.
OAuth Scope = "openid", "email", "profile":
{
"id": "1041407476129264...",
"email": "[email protected]",
"verified_email": true,
"name": "Ming Xiao",
"given_name": "Ming",
"family_name": "Xiao",
"link": "https://plus.google.com/secret",
"picture": "https://lh6.googleusercontent.com/secret.jpg",
"locale": "en",
"hd": "secret.com"
}https://graph.facebook.com/me
Method: GET.
Arguments:
access_token: Your OAuth2 Access Token.
Default Scope: public_profile:
{
"name":"Ryan Liu",
"id":"170879<...Secret...>"
}https://api.github.com/user
Method: GET.
Arguments:
access_token: Your OAuth2 Access Token.
No explicit scope.
{
"login": "octocat",
"id": 1,
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false,
"name": "monalisa octocat",
"company": "GitHub",
"blog": "https://github.com/blog",
"location": "San Francisco",
"email": "[email protected]",
"hireable": false,
"bio": "There once was...",
"public_repos": 2,
"public_gists": 1,
"followers": 20,
"following": 0,
"created_at": "2008-01-14T04:33:35Z",
"updated_at": "2008-01-14T04:33:35Z"
}Scope = user:
{
"login": "octocat",
"id": 1,
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false,
"name": "monalisa octocat",
"company": "GitHub",
"blog": "https://github.com/blog",
"location": "San Francisco",
"email": "[email protected]",
"hireable": false,
"bio": "There once was...",
"public_repos": 2,
"public_gists": 1,
"followers": 20,
"following": 0,
"created_at": "2008-01-14T04:33:35Z",
"updated_at": "2008-01-14T04:33:35Z",
"total_private_repos": 100,
"owned_private_repos": 100,
"private_gists": 81,
"disk_usage": 10000,
"collaborators": 8,
"two_factor_authentication": true,
"plan": {
"name": "Medium",
"space": 400,
"private_repos": 20,
"collaborators": 0
}
}Note that Weibo user ID is returned along with OAuth access token, see Docs.
https://api.weibo.com/oauth2/access_token
Method: POST.
Arguments:
client_id: OAuth2 client ID.client_secret: OAuth2 client secret.grant_type: should beauthorization_codeas Docs say.code: the authorization code.redirect_uri: callback URL.
{
"access_token": "ACCESS_TOKEN",
"expires_in": 1234,
"remind_in":"798114",
"uid":"12341234"
}Docs.
https://graph.qq.com/oauth2.0/me
Method: GET.
Arguments:
access_token: Your OAuth2 Access Token.
Note that the response text from QQ is not a valid JSON, you need to parse it carefully.
callback( {"client_id":"YOUR_APPID","openid":"YOUR_OPENID"} );