GoogleAuthException: Unknown when authenticating with Cloud Endpoints

后端 未结 2 1666
旧时难觅i
旧时难觅i 2021-02-09 04:33

I\'m trying to add authentication to my Cloud Endpoints, but I can\'t get it to work. I\'m using this blog as a guideline: http://devthots.blogspot.nl/2012/07/building-awesome-a

2条回答
  •  暖寄归人
    2021-02-09 05:28

    Using

    GoogleAccountCredential credential = GoogleAccountCredential.usingAudience(MainActivity.this, "server:client_id:12312312312-abcdefghijklmnopqrstuvw012345678.apps.googleusercontent.com");
    

    and

    @Api(name = "noteendpoint", clientIds = { Ids.WEB_CLIENT_ID,
            Ids.ANDROID_CLIENT_ID }, audiences = { Ids.ANDROID_AUDIENCE }, namespace = @ApiNamespace(ownerDomain = "example.com", ownerName = "example.com", packagePath = "test"))
    public class NoteEndpoint {
    
        public class Ids {
            public static final String WEB_CLIENT_ID = "12312312312312-abcdefghijklmnopqrstuvwxyz012345678.apps.googleusercontent.com";
            public static final String ANDROID_CLIENT_ID = "12312312312312-0123456789abcdefghabcdefghabcdefgha.apps.googleusercontent.com";
            public static final String ANDROID_AUDIENCE = WEB_CLIENT_ID;
        }
    

    solved the problem.

提交回复
热议问题