gitbook关联github报错:This credential is already associated with a different user account.

报错

笔者在gitbook上,对Organization中的一个Space进行和Github的关联时,产生了This credential is already associated with a different user account这个错误。
gitbook关联github报错:This credential is already associated with a different user account.

原因

根据提示,是因为该凭证早已和另一个用户账号进行了关联。
最后才知道,笔者最开始是用邮箱注册了一个gitbook账号(姑且称为账号A),前两天又利用github账号关联登录了gitbook(账号B,SIGN IN WITH GitHub)。这是两个不同的账号,虽然那个邮箱就是我github里设置的邮箱。下图可以证明:

gitbook关联github报错:This credential is already associated with a different user account.
而之前笔者就在账号B上尝试过同步github仓库与gitbook书籍。如今在账号A上再尝试同步github仓库与gitbook书籍就报错了。这个也从侧面证明了,一个gitbook账号只能与一个github账号里的仓库相关联

探错

登录github,在Settings -> Security log中查找相关信息,发现一条如下记录:
gitbook关联github报错:This credential is already associated with a different user account.
发现一个新名词:OAuth

开放授权(OAuth)是一个开放标准,允许用户让第三方应用访问该用户在某一网站上存储的私密的资源(如照片,视频,联系人列表),而无需将用户名和密码提供给第三方应用

然后在Settings -> Applications -> Authorized OAuth Apps发现如下信息:

gitbook关联github报错:This credential is already associated with a different user account.
好家伙,直接将它Revoke,不给它授权。

gitbook关联github报错:This credential is already associated with a different user account.
移除权限之后,再到gitbook尝试关联github。
Integrations -> Github
弹出重新授权的界面
点击授权
以为自己找到了正确的方法

没想到!还是报了一样的错!????
虽然这条路没有真正的解决掉问题,但对后面的解决方法还是起到了战略性的意义。

解决方法

要么采用最开始关联的gitbook账号,要么删除最开始关联的gitbook账号与已关联github的凭证(credential),以采用另一个gitbook账号。
笔者想用上文中提到的账号A,那么就需要删除那个凭证。
那个凭证到底是什么?笔者曾经怀疑过是OAuth,但是实践过后发现并不是。
因此最后采取的办法是——注销最开始关联的gitbook账号(上文中提到的账号B):
Settings -> Delete Account
gitbook关联github报错:This credential is already associated with a different user account.

解决成功

登录gitbook,选择一个Space,Integrations -> GitHub,可以选择列出所有仓库,还是所有公开仓库。
gitbook关联github报错:This credential is already associated with a different user account.
确定授权(如果没有弹出这个界面,可以按上文中提过的方法在github中先移除权限)
gitbook关联github报错:This credential is already associated with a different user account.
选择仓库
gitbook关联github报错:This credential is already associated with a different user account.
选择分支
gitbook关联github报错:This credential is already associated with a different user account.
选择是gitbook同步github还是github同步gitbook
gitbook关联github报错:This credential is already associated with a different user account.
关联成功
gitbook关联github报错:This credential is already associated with a different user account.