我正在关注Github的OAuth流程,并获得一个访问令牌,使我能够访问用户的电子邮件范围.当我使用https://github.com/login/oauth/access_token端点交换访问令牌的代码时,我得到以下响应:
{
access_token: '83f42..xxx’,
token_type: 'bearer',
scope: 'user:email'
}
Run Code Online (Sandbox Code Playgroud)
看起来很棒.所以我发出这个请求,使用令牌获取我的用户数据:
Accept-Language: en-us
Accept: application/json
Authorization: token 83f42..xxx
Accept-Encoding: gzip, deflate
GET https://api.github.com/user
Run Code Online (Sandbox Code Playgroud)
我确实将我的用户对象作为响应,但email属性为null.其他人有这个问题吗?
我花了一天时间与Angular2一起潜入RxJS,因为将用户界面建模为流的做法对我来说是新的.
我正在尝试提供User对象流的用户服务.User当用户通过身份验证时,将提供第一个对象.User当用户更新时可以提供附加对象,例如他们更新他们的简档.如果在应用程序加载时未记录用户,或者他们注销,则会null发出.
因此,组件中的观察器实现如下所示:
export class AppComponent {
private user: User;
private showLoginForm: boolean;
constructor(public userService: UserService) { }
ngOnInit() {
this.userService.user$.subscribe(user => {
this.user = user;
this.showLoginForm = this.user ? false : true;
})
}
}
Run Code Online (Sandbox Code Playgroud)
的userService.user$可观察到的是一个BehaviorSubject类型.这是你如何实现这个?发送null到期望User对象的流的想法并不适合我.但与此同时,它确实提供了回答问题的便捷方式:用户是否可用?
我试图在OSX 10.9上从这个源代码编译kyoto cabinet:
http://fallabs.com/kyotocabinet/pkg/kyotocabinet-1.2.76.tar.gz
但它失败了:
In file included from kcutil.cc:16:
In file included from ./kcutil.h:19:
./kccommon.h:92:10: fatal error: 'tr1/unordered_map' file not found
#include <tr1/unordered_map>
^
2 warnings and 1 error generated.
make: *** [kcutil.o] Error 1
Run Code Online (Sandbox Code Playgroud)
我的理解是,OSX 10.9中的C++库发生了变化,但我不确定如何导航到解决方案.任何帮助,将不胜感激.