Python Atlasapi身份验证

时间:2020-05-05 19:33:30

标签: python mongodb-atlas

我正在尝试使用atlasapi向Atlas进行身份验证。我正在使用我的Google帐户,并通过以下方法收到错误ErrAtlasUnauthorized: Authentication is required。是否支持google auth或我做错了什么?

from atlasapi.atlas import Atlas
auth = Atlas("foo@google.com","<password>","<groupId>")
clusters = auth.Clusters.get_all_clusters
print (clusters())

完整跟踪:

ErrAtlasUnauthorized                      Traceback (most recent call last)
<ipython-input-61-d69a101fdf69> in <module>
      1 clusters = auth.Clusters.get_all_clusters
----> 2 print (clusters())

C:\...\atlasapi\atlas.py in get_all_clusters(self, pageNum, itemsPerPage, iterable)
    129 
    130             uri = Settings.api_resources["Clusters"]["Get All Clusters"] % (self.atlas.group, pageNum, itemsPerPage)
--> 131             return self.atlas.network.get(Settings.BASE_URL + uri)
    132 
    133         def get_single_cluster(self, cluster: str) -> dict:

C:\...\atlasapi\network.py in get(self, uri)
    144             logger.debug("Auth information = {} {}".format(self.user, self.password))
    145 
--> 146             return self.answer(r.status_code, r.json())
    147 
    148         except Exception:

C:\...\atlasapi\network.py in answer(self, c, details)
     68             raise ErrAtlasBadRequest(c, details)
     69         elif c == Settings.UNAUTHORIZED:
---> 70             raise ErrAtlasUnauthorized(c, details)
     71         elif c == Settings.FORBIDDEN:
     72             raise ErrAtlasForbidden(c, details)

ErrAtlasUnauthorized: Authentication is required

1 个答案:

答案 0 :(得分:0)

API访问密钥是您的用户名/密码。

相关问题