我正在尝试使用Android上的sdk从Google+获取授权令牌,但它总是会引发"GoogleAuthException Unknown"
这是我使用的代码:
private static final String LOGIN_SCOPES =
"https://www.googleapis.com/auth/plus.login " +
"https://www.googleapis.com/auth/userinfo.email";
protected static final String SCOPES =
"oauth2:server:client_id:" +
BuildConfig.GOOGLE_SERVER_CLIENT_ID +
":api_scope:" +
LOGIN_SCOPES;
String token = GoogleAuthUtil.getToken(
getApplicationContext(),
Plus.AccountApi.getAccountName(googleApiClient),
SCOPES);
Run Code Online (Sandbox Code Playgroud)
我加倍检查了我从谷歌控制台获得的client_id.
真正令人不安的是,这段代码适用于我的暂存风格,有一个staging client_id,但对于我今天早上创建的我的生产client_id,我无法使其工作.
任何的想法 ?
我已经实现了我认为在类中进行双重检查锁定以实现线程安全的延迟加载.
万一你想知道,这是我目前正在研究的DI库.
我正在谈论的代码如下:
final class Builder<I> {
private let body: () -> I
private var instance: I?
private let instanceLocker = NSLock()
private var isSet = false
private let isSetDispatchQueue = DispatchQueue(label: "\(Builder.self)", attributes: .concurrent)
init(body: @escaping () -> I) {
self.body = body
}
private var syncIsSet: Bool {
set {
isSetDispatchQueue.async(flags: .barrier) {
self.isSet = newValue
}
}
get {
var isSet = false
isSetDispatchQueue.sync {
isSet = self.isSet
}
return isSet
}
} …Run Code Online (Sandbox Code Playgroud) multithreading lazy-loading double-checked-locking swift swift4