How to create a instance of UserCredential if I already have the value of Access Token?

后端 未结 2 987
温柔的废话
温柔的废话 2020-12-05 20:47

So I have this code
My question is how do I configure the UserCredential if I\'m already authenticated via OAuth?

The current scenario is the c

2条回答
  •  感情败类
    2020-12-05 21:07

    We can create GoogleCredential directly from the access token and use it instead of UserCredential as well. I just think it might be helpful for someone. Here is a code snippet of GmailService initialization:

    GoogleCredential cred = GoogleCredential.FromAccessToken(accessToken);
    GmailService service = new GmailService(new BaseClientService.Initializer {HttpClientInitializer = cred});
    

提交回复
热议问题