集成Google登录

客户端登录

1. 获取idToken

# 用到的scope
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile'

2. 与服务器验证

网页登录(需后台配置重定向url)

使用自己的WebView登录,需要使用标准的浏览器UA,否则invalid_client

登录url:

https://accounts.google.com/signin/oauth?client_id=$client_id&redirect_uri=$redirect_url&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&state=try_sample_request&include_granted_scopes=true&response_type=token&o2v=2&as=as

范例url:

https://accounts.google.com/signin/oauth?client_id=594286495522-7se42u6rshlmg5g4nvanp1tsa09005oc.apps.googleusercontent.com&redirect_uri=https://example-app.com/oauth/google&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&state=try_sample_request&include_granted_scopes=true&response_type=token&o2v=2&as=jiBedIuNisz17yKB-XQAOQ

本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!