AWS Cognito - Get google refresh_token and add scopes to access_token

Viewed 22

I am using

import { Auth } from 'aws-amplify';    

Auth.federatedSignIn({ provider: "Google" })

so I can create a new user to my user pool using google authentication. After the user is created I would like to use the google spreadsheet api. There are two issues on that. First, I go to cognito console and do some attribute mapping. In the google tab I map access_token and refresh_token to two custom attributes I created. But in the

Auth.currentAuthenticatedUser()

I get only the access_token and not the refresh_token so after the access_token expires then, while I will still be logged in and able to access the AWS APIs, I will not be able to access the Google Apis, so I will need to login again only for that.

The second issue is that even if I have the access_token, I am not able to add the appropriate scopes in order to use the APIs that I want. Am I able to more scopes apart from the default ones?

   "scope": [
        "phone",
        "email",
        "openid",
        "profile",
        "aws.cognito.signin.user.admin"
    ],

like the

https://www.googleapis.com/auth/spreadsheets.readonly

If I add this to supported scopes I get an error:

 Error handling auth response. Error: invalid_scope
0 Answers
Related